希望这非常简单。
我希望根据其名称的字符串表示来动态调用对象。以下是我要做的一个例子:
public class Class1
{
public string Property1 { get; set; }
public string Property2 { get; set; }
public string Property3 { get; set; }
}
public class Class2
{
public string Property1 { get; set; }
public string Property2 { get; set; }
public string Property3 { get; set; }
}
我的目标是从字符串表示中调用Class2
(GetClassFromString()
显然已经组成,但希望能够描述我想要做的事情):
Object cls = Object.GetClassFromString("Class2");
然后cls
将是来自Class2
的对象。