这是演示我的问题的代码(都在同一个命名空间中):
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Fubar.BGroup.A = true;
}
public Foo Fubar = new Foo();
}
public class Foo
{
public Foo()
{
}
private BoolGroup bGroup = new BoolGroup();
public BoolGroup BGroup
{
get{ return this.bGroup; }
set
{
this.bGroup = value;
this.doSomething();
}
}
}
public class BoolGroup
{
public BoolGroup()
{
}
private bool a;
public bool A
{
get { return this.a; }
set { this.a = value; }
}
}
private void doSomething()
{
....
}
我永远不会做doSomething(),我真的很想。我究竟做错了什么?这些值都会正确设置,但我似乎从未进入 BGroup 的设置部分。
谢谢