Information Technology Reference
In-Depth Information
The mscorlib Library
There's a class library that I've been using in almost every example in the topic so far. It is the
one that contains the
Console
class. The
Console
class is defined in an assembly called
mscorlib
in a file called
mscorlib.dll
. You won't find this assembly listed in the
References
folder, how-
ever. Assembly
mscorlib
contains the definitions of the C# types, and the basic types for most
.NET languages. It must always be referenced when compiling a C# program, so Visual Studio
does not show it in the
References
folder.
When you take into account
mscorlib
, the compilation process for
MyWidgets
looks more
like the representation shown in Figure 10-3. After this, I will assume the use of the
mscorlib
assembly, without representing it again.
Figure 10-3.
Referencing class libraries
Now suppose that your program has been working fine with the
SquareWidget
class, but
you want to expand its capabilities to use a class called
CircleWidget
, which is defined in a dif-
ferent assembly called
UltraLib
. The
MyWidgets
source code now looks like the following. It
creates a
SquareWidget
object as defined in
SuperLib
, and a
CircleWidget
object as defined in
UltraLib
.
class WidgetsProgram
{
static void Main( )
{
SquareWidget sq = new SquareWidget(); // From SuperLib
...
CircleWidget circle = new CirclWidget(); // From UltraLib
...
}
}