Hi friends,
I want to know that If a namespace isn't supplied, which namespace does a class belong to?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Jan 21, 2012, 7:29 PM EST
VulpesRank #55 · 29.2K reputationPosted Jan 22, 2012, 12:21 AM EST
In the event of a name clash, you can clarify that a type (SomeType say) belongs to the global namespace using the following syntax:
global::SomeType
'global' is a contextual keyword (it's only a keyword when used in certain situations) and :: is called the scope resolution operator.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 22, 2012, 7:43 PM EST
A Namespace in Microsoft .Net is like containers of objects. They may contain unions, classes, structures, interfaces, enumerators and delegates. Main goal of using namespace in .Net is for creating a hierarchical organization of program. In this case a developer does not need to worry about the naming conflicts of classes, functions, variables etc., inside a project.
In Microsoft .Net, every program is created with a default namespace. This default namespace is called as global namespace. But the program itself can declare any number of namespaces, each of them with a unique name. The advantage is that every namespace can contain any number of classes, functions, variables and also namespaces etc., whose names are unique only inside the namespace. The members with the same name can be created in some other namespace without any compiler complaints from Microsoft .Net.
VulpesRank #55 · 29.2K reputationPosted Jan 23, 2012, 1:02 AM EST
The answer is that it doesn't support them directly but you can represent them in C# by applying some attributes to a struct or class. Check out these articles:
http://msdn.microsoft.com/en-us/library/acxa5b99(VS.80).aspx
http://www.c-sharpcorner.com/uploadfile/GemingLeader/marshaling-unions/