我有写与类名作为参数的功能,这是字符串的函数。所以,我需要创建这个类名称实例。
createInstance建立(串类名){
.............
//这里我需要创建类名的情况下,
.............
}
解决方案
Activator.CreateInstance(Type.GetType(类名));
I have to write a function with class Name as Parameter to function, which is in string. So that i need to create instance of this class name.
createInstance(string ClassName){
.............
//Here i Need to create instance of ClassName,
.............
}
解决方案
Activator.CreateInstance(Type.GetType(ClassName));