using System;
using System.Collections.Generic;
public class MainClass
{
static void Main() {
IList intList = (IList) CreateClosedType( typeof(List<>) );
IList doubleList = (IList) CreateClosedType( typeof(List<>) );
Console.WriteLine( intList );
Console.WriteLine( doubleList );
}
static object CreateClosedType( Type genericType ) {
Type[] typeArguments = {
typeof( T )
};
Type closedType = genericType.MakeGenericType( typeArguments );
return Activator.CreateInstance( closedType );
}
}
System.Collections.Generic.List`1[System.Int32]
System.Collections.Generic.List`1[System.Double]