A C# class with a null namespace

Posted by Richard Ev on Stack Overflow See other posts from Stack Overflow or by Richard Ev
Published on 2011-01-05T10:40:38Z Indexed on 2011/01/05 10:54 UTC
Read the original article Hit count: 165

Filed under:
|

While going through some legacy code today I discovered that you can declare a C# class without placing it in a namespace (in this scenario I have an ASP.NET WebForms application and some of the web forms are not declared within any namespace).

A GetType() on such a class returns a type where the namespace property is set to null.

I did not know that this was allowed - can anyone suggest why it would be desirable to have a class that is not declared within a namespace?

© Stack Overflow or respective owner

Related posts about c#

Related posts about namespaces