I have the following code
private static void Main(string[] args)
{
ClassC<ClassD> objC=new ClassC<ClassD>();
var tTypeName = "MyProject.ClassD";
ClassC<Type.GetType(tTypeName)>=new ClassC<Type.GetType(tTypeName)>();
}
}
public class ClassC<T>
{
///some code here
}
public class ClassD
{
///some code here
}
I will instantiate classc if I know the type T is ClassD like this
ClassC<ClassD> objC=new ClassC<ClassD>();
What if I know it during runtime, how can I pass ClassD type name to classc. I tried the following, it throw compilation error, Please advice.
var tTypeName = "MyProject.ClassD";
ClassC<Type.GetType(tTypeName)>=new ClassC<Type.GetType(tTypeName)>