What namespace will a class have if no namespace is defined

后端 未结 3 2166
半阙折子戏
半阙折子戏 2020-11-30 08:33

In C#, if I create a class with no namespace, what namespace will I use when trying to instantiate the class?

For example, assume main is...

namespac         


        
3条回答
  •  长情又很酷
    2020-11-30 09:02

    In the addition to above answers, it is important to note, what all Type, regardless of its declaration location, has a "fully qualified name", which begins from "global::"

    From "O'Relly. C# in a Nutshell":

    All type names are converted to fully qualified names at compile time. Intermediate Language (IL) code contains no unqualified or partially qualified names

提交回复
热议问题