#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:

Advertisement