#711 – The Global Namespace

Types and namespaces are normally defined within a namespace, creating a hierarchy of namespaces which in turn contain types.

In the example below, the ConsoleApplication1 namespace contains the Program type.

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hi");
        }
    }
}

This structure will appear in the IL Disassembler as shown below. Note that the fully qualified name of the Program type includes the namespace.

You can also declare a type that is not inside of a namespace.  The type will instead be declared as part of what’s known as the global namespace.  In the example below, the Program type is declared directly in the global namespace.

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hi");
    }
}

This appears in the IL Disassembler as:

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: