我经常遇到这个问题,我并不真正了解如何将用户表单变量传递到类中。例如我有一个按钮:
private void button1_Click(object sender, EventArgs e)
{
DoStuff();
}
和表单类中的一个方法:
DoStuff()
{
Class123 myclass = new Class123();
}
...
...
class Class123
{
//how do i pass for example in myotherClass whether or not my checkbox on the userform is checked? i dont want to have to pass from method to method to class to class. what is the logical/smart way of handling this?
ClassData myotherClass = new ClassData();
}
例如,我如何在 myotherClass 中传递我的用户表单上的复选框是否被选中?我不想必须从方法传递到方法到类到类。处理此问题的逻辑/智能方式是什么?