Hi everybody, I have a problem here. I have a class library namely ClLib, and has the following 8 cs files.
- 1E1
- 1E2
- 1E3
- 1N1
- 1N2
- 1N3
I have also created a Windows App in Visual Studio, and I need to create a directive like "using ClLib.Express.1E1". How do I go about it? I am stuck in this situation whereby when I want to change the namespace of 1E1 from "namespace ClLib" to "namespace ClLib.Express.1E1". An error occurs, as the namespace ClLib has already contain one definition for Express.
A great thanks and appreciation in advance for all kind souls who are willing to help me:)

1 answers
The 'using' directive only imports namespaces - it doesn't directly import classes or their members.
If your class library, ClLib.dll, has a namespace called ClLib, then in your Windows app you just want:
using ClLib;
To create an instance of your Express class (assuming it has a constructor which takes no parameters) you can then do:
Express exp = new Express();
I don't know what 1E1 etc are but they're not legal identifiers in C# and so won't compile. A legal identifier must begin with either a letter or an underscore.
Although it's not used very often, there's also a variant of the 'using' directive which enables you to create an alias for a class:
using Exp = ClLib.Express;
We can now use 'Exp' instead of 'Express':
Exp exp = new Exp();
However, there's little point unless you're abbreviating a very long name or want to avoid confusion with a similarly named class in another namespace.
answered 2 years ago by:
17279