|
Listing 13-21 extracted from chapter
Generics
Listing 13-20< > Listing 13-22
This listing can be compiled with the command line: csc.exe /target:exe Example_13_21.cs Errors: 0 Warnings: 0
Example_13_21.cs
class C<T>{
public static void PrintTypes(){
System.Console.WriteLine( typeof( T ).Name );
System.Console.WriteLine( typeof( C<T> ).Name );
System.Console.WriteLine( typeof( C<C<T>> ).Name );
if( typeof( C<T> ) != typeof( C<C<T>> ) ) {
System.Console.WriteLine("Despite a similar name" +
" they are different instances of Type.");
}
}
}
class Program {
static void Main() {
C<string>.PrintTypes();
C<int>.PrintTypes();
}
}
Copyright Patrick Smacchia 2006 2007
|