Hi everybody. I have this problem that is puzzling me and I am unable to solve it at all. I have two files and they are:
ClLib1
ClassLibraryApp1
As the name suggests, the "ClLib1" holds the DLL file, whereas the "ClassLibraryApp1" is a Windows Application used to test the DLL file. And so, I have a few .cs file in ClLib1 namely bye2009.cs and hello2010.cs. These two files are located under a file called Year.cs. While I was trying to put in "using ClLib1;" in ClassLibraryApp1 (whereby I've already added the reference from the ClLib's bin folder), I realise I am unable to put "using ClLib1.bye2009".
How do I go about solving this?

1 answers
The 'using' directive imports namespaces into the current file - in other words, it enables you to uses classes which are defined in different namespaces (either in the current assembly or a different assembly) without the need to qualify them with the namespace name.
To use classes in a different assembly (CILib1) from the current assembly (ClassLibraryApp1) you first need to add a reference to CILib1.dll to the current project which you say you've done.
The .cs files which make up CILib1.dll are immaterial once the library has been compiled. It just becomes one big collection of namespaces and classes.
So if, for example, CILib1.dll contains a class called bye2009 which is in a namespace called CILib1, then to use that from ClassLibraryApp1 you have two choices:
1. Add this using directive:
using CILib1;
You can then refer to bye2009 without fully qualifying it:
bye2009 bye = new bye2009();
2. Don't bother with the using directive but fully qualify the class name instead:
CILib1.bye2009 bye = new CILib1.bye2009();
It's also possible to provide an alias for a class with the 'using' directive. For example:
using Bye = CILib1.bye2009;
You can then do:
Bye bye = new Bye();
answered 2 years ago by:
17279