大致的一个问题框架
public partial class MainWindow : Window
{
public PersonBasicInfo person_cr = new PersonBasicInfo();
private void button1_Click(object sender, RoutedEventArgs e)
{
PersonBasicInfo person_cr= new PersonBasicInfo();
}
}
请问这两个 person_cr 作用域范围有什么区别?
public partial class MainWindow : Window
{
public PersonBasicInfo person_cr = new PersonBasicInfo();
private void button1_Click(object sender, RoutedEventArgs e)
{
person_cr
}
}
为什么有时候这么写会报person_cr没有实例化?
求解
------解决思路----------------------
button1_Click方法内部的person_cr是方法内部的,不是类的person_cr
至于报person_cr未实例化,这个就不知道了,至少看你代码是不可能的