Information Technology Reference
In-Depth Information
Many different class types can be constructed from the same generic class. Each one is
a separate class type, just as if it had its own separate non-generic class declaration.
For example, the following code shows the creation of two types from generic class
SomeClass . The code is illustrated in Figure 19-7.
One type is constructed with types short and int .
￿
￿
The other is constructed with types int and long .
class SomeClass< T1, T2 > // Generic class
{
...
}
class Program // Program
{
static void Main() // Main
{
SomeClass<short, int> First = // Constructed type
new SomeClass<short, int>();
SomeClass<int, long> Second = // Constructed type
new SomeClass<int, long>();
...
Figure 19-7. Two constructed classes created from a generic class
Search WWH ::




Custom Search