I am not realy sure what you want to achieve.
For example
namespace MyCompany.MyProduct.MyServices.MyColorService.Enums
{
public enum Color
{
Green,
Red
}
}
Now we want to use it:
using MyCompany.MyProduct.MyServices.MyColorService.Enums;
public class Foo
{
public void Bar()
{
var currentColor = Color.Green;
}
}
Compare this to:
public class Foo
{
public void Bar()
{
var currentXx = xx.Green;
}
}
- On the first example, I Immediately see it is a color. The green one. Also I immediately see, it is our custom color, and not the one from
System.Drawing
.
- On the second example, I only know, it is some
green
of xx
? Is it a green soldier? Is it environment friendly?
What ever you are trying to do, it makes things worse.
Main point here is to avoid using xx = MyNameSpace.MyLongEnumName;
in the top of .cs files of derived classes.
That's not how namespaces working. Namespaces are there, to make sure, you have no naming conflict with other libraries. They are here, to ensure that you are operating on the type you realy want. That's why your derived class also has a own namespace.
Or in other words: What you want to achieve is not possible. Even when it would be possible, it probably make things worse!
Tldr: Make sure, you organize your Code. Create a balance between too verbose names and too simple names.
Aside from that, write Color
, set the cursor over it and press ctrl + ., then enter. You will notice Visual Studio will automaticaly imports for you the namespace, or offers a list, if the name is ambigious. Also we have tools like Resharper, which are importing the namespace while using intellisense ;)