Don't ask me why, but I need to do the following:
string cName = "ClassA";
List<cName> l = new List<cName>();
How can I do it?
my code:
public void MergeForm(List<object> lModel)
{
string className = lModel[0].GetType().Name;
List<className> list = new List<className>();
}
object - it is a class
You cannot have
List<cName>
as static type, but you can create the instance:cName
needs to be the fully qualified name, though.Use
Assemmbly.GetTypes
:If you have the full type name, you can use
Assemmbly.GetType
.If you have the full type name and assembly-qualified name, and the type you seek is in another assembly, then use
Type.GetType
.Take a look at the Activator.CreateInstance method.