Suppose that, in C#, myType
is a reference to some Type
.
Using myType
only, is it possible to create a List
of objects of myType
?
For example, in the code below, although it is erroneous, I'd like to instantiate via
new List
.<
myType>
( )
using System ;
using System.Reflection ;
using System.Collections.Generic ;
class MyClass
{
}
class MainClass
{
public static void Main ( string [] args )
{
Type myType = typeof ( MyClass ) ;
List < myType > myList = new List < myType > ( ) ;
}
}