有人建议我如何简化以下代码
private bool isMethodCalled;
private void CallMethod()
{
if (!isMethodCalled)
{
this.CallCertainMethod();
isMethodCalled = true;
}
}
private int field1;
public int Property1
{
get
{
CallMethod();
return this.field1;
}
set { this.field1 = value; }
}
private int field2;
public int Property2
{
get
{
CallMethod();
return this.field2;
}
set { this.field2 = value; }
}
private int field3;
public int Property3
{
get
{
CallMethod();
return this.field3;
}
set { this.field3 = value; }
}