|
Listing 13-39 extracted from chapter
Generics
Listing 13-38< > Listing 13-40
This listing can be compiled with the command line: csc.exe /target:exe Example_13_39.cs Errors: 0 Warnings: 0
Example_13_39.cs
using System;
using System.Collections.Generic;
class Program {
static void Main() {
List<int> list = new List<int>();
Type type1 = list.GetType();
Type type2 = typeof( List<int> );
Type type3 = typeof( List<double> );
// type4 is an open generic type.
Type type4 = type3.GetGenericTypeDefinition();
System.Diagnostics.Debug.Assert( type1 == type2 );
System.Diagnostics.Debug.Assert( type1!= type3 );
System.Diagnostics.Debug.Assert( type3!= type4 );
}
}
Copyright Patrick Smacchia 2006 2007
|