C# namespace structure forcing me to use alias -


i'm playing around namespaces , faced problem can't understand.

my namespace structure in given class library follows:

namespace history namespace history.antiquity namespace history.antiquity.east namespace history.antiquity.west 

when inside source file declares namespace history, can't use of types defined under history.antiquity.east or history.antiquity.west without qualifying them, or without qualifying them starting "antiquity".

example code:

the following instance, gives me compile-time error (assuming type "persia" defined in history.antiquity.east):

using history.antiquity;  namespace history {     public class foo     {         public foo()         {             east.persia.conquer(); // error!         }     }  }  

i need either qualify persia, or qualify starting antiquity. alternatively, can introduce alias:

using east = history.antiquity.east; 

actual question:

what can't seem understand why there problem namespace structure. how can .net finds conflicting?

you have open namespace in order see it's types in c#. types sub-namesapces not automatically visible. so, put following on top of code file:

using history.antiquity.east; 

then can directly access type follows:

persia.conquer(); 

by way, code samples mixture of vb, c# , c++/cli... language using?


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -