Generic Type specification during runtime
is there any way of specifying the type of a generic class during runtime instead of at compile time?
my problem is that i have file several different versions of a file with each version having different properties and methods and it is not unitl compile time that i can findout what version of the file it is. Below is examples of the classes that i have
public class version1_0
{
//example member
public int total;
}
public class version2_2
{
//example member
public string extendedDesc;
}
public Gen<T>
{
public T file;
//other methods are here
}
public enum Versions
{
v1, //represents the version1_0 class
v2 //represents the version2_2 class
}
i want to add the generic class "Gen" to the class below using the _file variable and then set the type of the generic class Gen by the version that was passed into the constructor so i can specify the type of the Gen variable at compile time only at run time.
public class myFile
{
private Gen??? _file;
public myFile(Versions)
{
//set type of _file here by using Versions enum.
}
}
is there any other way that i could go about solving this problem?
many thanks in advance.
Glenn
|