所以基本上我已经遇到了这个类的一些readonly
属性,该类的作者告诉我,我可以为特定任务进行设置。问题在于,他们大多数时间都是通过操纵获得价值,而不是直接从班级中的私人变量中获取价值。使只读属性可设置
例子:
public decimal? AccruedInterest
{
get
{
if (this.Result != null)
{
return this.GetExchangedCurrencyValue(this.Result.AccruedInterest.GetValueOrDefault(decimal.Zero));
}
return null;
}
}
所以,如果我想添加一个二传手,我不想担心设置该Result
对象,因为我不知道,如果它的方式回到了它的将是正确绘制。
我能做这样的事吗?
private decimal? _AccruedInterest;
public decimal? AccruedInterest
{
get
{
if (this._AccruedInterest.HasValue)
{
return this._AccruedInterest.Value;
}
if (this.Result != null)
{
return this.GetExchangedCurrencyValue(this.Result.AccruedInterest.GetValueOrDefault(decimal.Zero));
}
return null;
}
set
{
this._AccruedInterest = value;
}
}
或者你们有没有看到可能由此产生的问题(除了现在可以改变的事实)?
你的问题到底是什么?你应该问这个人他们决定制造这些房产的原因,然后迅速地将他们打包,因为暗示你有一些破解来改变他们的价值。 –