<分区>
我的类中有一个属性在 set 访问器中有很多逻辑:
private String text;
public String Text
{
get { return text; }
private set
{
// some actions with a value
value = value.Replace('a', 'b');
text = value;
}
}
如何防止其他开发人员(甚至我)更改此类中的 field 而不是 property?
如果有人这样写:
public Test(String text)
{
this.text = text;
}
它会破坏我的类的逻辑!