【发布时间】:2012-01-04 16:25:15
【问题描述】:
我想在类中调用构造函数,例如: 公共类 Myclass(){
public MyClass(){
//......
}
public MyClass(int id):this(){
//......
}
private void Reset(){
//.....
this = new MyClass(id); //here I want to call constructor
//......
}
}
但它不起作用。有可能吗?如果可以,我该怎么做?
【问题讨论】:
-
您为什么要这样做?您不能在实例方法中以这种方式更改
this指针,也不应该这样做。
标签: c#