c# - 'Class' is a namespace but is used like a 'type' -


first, not same many highly upvoted questions on exact topic unless i'm missing 1 of them. of them point issue have namespace same name class. not case (but was).

i started out creating new console application called batchresizer , put couple of classes there, decided move class library, called batchresizer.components; renamed original console application batchresizer.consolerunner, changed classes in project namespace batchresizer.consolerunner.[...], set assembly name , default namespace same.

there class titled batchresizer there no namespaces titled [...].batchresizer in project anymore, when var batchresizer = new batchresizer() error namespace used class. there are items named batchresizer.consolerunner.[...] or batchresizer.components.[...], nothing ending in batchresizer.

i've tried "cleaning" , rebulding project, deleting .suo file, deleting /bin folder of projects in solution, , i've went through every class in related projects namespace collisions.

batchresizer still namespace name, though. if it's same name class, you'll have more explicit:

var batchresizer = new components.batchresizer(); 

you add using statement within namespace:

namespace batchresizer.consolerunner {     using components;         internal class program     {                 private static void main(string[] args)         {             var batchresizer = new batchresizer();         }     } } 

if want bit geeky, c# 5.0 spec has say:

9.2 namespace declarations

...the qualified-identifier of namespace-declaration may single identifier or sequence of identifiers separated “.” tokens. latter form permits program define nested namespace without lexically nesting several namespace declarations. example,

namespace n1.n2 {     class {}     class b {} } 

is semantically equivalent to

namespace n1 {     namespace n2     {         class {}         class b {}     } } 

so if, say, no class declared in namespace batchresizer, batchresizer is declared namespace.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -