Tech Off Thread

5 posts

Unknown C# Keyword 'global' with C syntax. What the @#$!

Back to Forum: Tech Off
  • User profile image
    JoshB

    I really like the work Visual Studio saves you from having to do, especially when implementing from an interface; gives you the option to populate your class with the members necessary to implement the interface. Today I ran into something I haven't seen before.

    <code>
    public
    object Deliverable
    {
       get { throw new global :: System.NotImplementedException(); }
    }
    </code>

    I searched the msdn, specifically the C# Language reference but didn't see any keyword for global. Can someone explain to me what the get accessor is actually throwing. Also, I've only seen the double colons '::' in c code and didn't realize that was available in C#, however I have no idea what the hell it does.

  • User profile image
    littleguru

    I don't know who invented this keyword, but global:: returns the Global Namespace root. Try to type it in Visual Studio. Intellisense will show you all classes that aren't in a namespace and all Root-Namespaces, such as System., Microsoft. etc.

    Probably it comes from VC++ - but I don't know it exactly.

    Ps. Throws NotImplementedException in the System-namespace Wink

  • User profile image
    chuawenching

    throw new global :: System.NotImplementedException();
    --> global probably is created by 3rd party

    --> Using :: should be in C++ right?

    (correct me if i am wrong)

  • User profile image
    SorinD

    The global keyword and the :: accessor are new features of the new C# 2.0 language which will be released with .NET Framework 2.0 and Visual Studio 2005.

    Don't try to compile C# 2.0 code with a C# 1.0 compiler (from Visual Studio .NET 2002 or 2003).

  • User profile image
    chuawenching

    I think it is time for me to learn C# 2.0 features. Thanks for the tips SorinD Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.