I am building a class library and using its default namespace as "System". There suppose I am creating a generic data structure say PriorityQueue and putting it under System.Collections.Generic namespace.

Now when I am referencing that library from another project, I can't see PriorityQueue under "System.Collections.Generic" namespace anymore. Though the library is referenced I can not access any of the classes in it.

Can anyone shed some light on it please. I know that if I change the namespace everything will be ok, but I want to create a seamless integration like .net framework itself with other project, so that one can refer the library and forget about its namespaces.

+2  A: 

Putting stuff in system namespaces is a bad idea. Firstly it's better to know explicitly where the stuff your using is. However more importantly, if Microsoft releases new stuff that causes a naming conflict with yours, your stuff breaks.

The second reason is probably why you cant see your code.

Josh Sterling
+2  A: 

If you are using the System namespace for your classes, then they will be found in System.

If you want them to be found in System.Collections.Generic, then you need to place them there.

But let's be clear, placing classes in System.* is a bad idea.

Scott Weinstein
+1  A: 

Just create your own namespace, e.g. Anindya.Collections.Generic, as placing classes in predefined framework namespaces isn't a good idea. MS might introduce a same class in a later framework, leading to problems.

+3  A: 

This is a very bad idea. Pretend you didn't think it up, and use a real namespace.

One does not have "seamless integration" with the .NET Framework, either. If we want to access the List<T> class, then we have to write

using System.Collections.Generic;

If you put your class in MyCompany.Collections.Generic, then you'll get exactly the same level of "seamlessness" that is achieved by the .NET Framework itself.

John Saunders
I know very well that changing the namespace will work and that's what I have been doing for long. But this time I did an experimentation and it failed. My question is that mscorlib and System.dll shares the same namespace but why can't mine? This was my original question. Sorry for being fuzzy.
Anindya Chatterjee
@Anindya Chatterjee What if everyone attempted to use your idea?

In case it wasn't clear: This is a REALLY bad idea.

The System name space should be considered reserved and verboten. If Microsoft decides to introduce a class in a framework update that conflicts with your System.mycrap.blah identifier in the future, you're going to have some pretty hefty refactoring on your hands, and, in the case of an app that's deployed to a client, an emergency update and potential liability for system downtime.

You wouldn't create your own class called "String." By the same token (pun), don't use reserved namespaces.

Also, the namespace "System" doesn't really describe the contents of your namespace. Typically, namespaces should mean something - like, BlogEngine, DatabaseCore, etc. Slapping everything into System is a lot like naming all of your variables "x," or "temp," and implies that the creator doesn't really understand the point of this level of code delineation and organization.

David Lively
+1  A: 

Did somebody mention yet that this is a bad idea? There are few reasons you wouldn't be able to see the class. Short from the assembly reference, there is only one good one: you forgot to declare the class public.

Hans Passant
+1 for actually mentioning a reason that the class wouldn't be visible.
David Lively
:) Sorry this is not the case.
Anindya Chatterjee

Please see my answer to the duplicate post: