Information Technology Reference
In-Depth Information
The source code for class library
UltraLib
is shown in the following example. Notice that
besides class
CircleWidget
, like library
SuperLib
, it also declares a class called
SquareWidget
.
You can compile
UltraLib
to a DLL and add it to the list of references in project
MyWidgets
.
public class SquareWidget
{
...
}
public class CircleWidget
{
public double Radius = 0;
public double Area
{
get { ... }
}
}
When you attempt to compile program
MyWidgets
, however, the compiler produces an
error message, because it doesn't know which version of class
SquareWidget
to instantiate. This
name clash
is illustrated in Figure 10-4.
Figure 10-4.
Since assemblies SuperLib and UltraLib both contain declarations for a class called
SquareWidget, the compiler doesn't know which one to instantiate.