我的代码有问题。我有2个班级:
当我的线程运行时,我想从我的clsSMS类修改它们的属性。
public class clsSMS
{
clsWorker objclsWorker;
public clsSMS(clsWorker objclsWorker = null)
{
this.objclsWorker.operatorBlocageError38();
// The above call doesn't work...
// I think the objclsWorker is always null...
// What do you think?
}
}
public class clsWorker
{
public clsSMS clsobjSMS;
public clsWorker(...)
{
this.clsobjSMS = new clsSMS(objclsWorker: this);
}
public void operatorBlocageError38(/*String port_concerne, bool erreur38*/)
{
MessageBox.Show("The method call work fine!");
}
}
答案 0 :(得分:0)
从发布的代码中看不出您曾经实例化过clsWorker。
clsWorker worker = new clsWorker();
worker.operatorBlocageError38();
如果在实例化之前调用operatorBlocageError38,则必须将该方法标记为static。
public static void operatorBlocageError38()