例如:
class TestType
{
public int a;
public int b;
}
TestType obj = Activator.CreateInstance(typeof(TestType), 1, 2) as TestType;
那么 obj.a==1
和 obj.b==2
呢?有人知道如何解决我的问题吗?
最佳答案
不可能,试试吧
TestType obj = Activator.CreateInstance(typeof(TestType)) as TestType;
obj.a = 1;
obj.b = 2;
关于c# - 如何 Activator.CreateInstance 一个没有构造函数的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54006665/