我写了这个属性并得到错误,它无法找到setter属性,当我添加setter时,我收到一个错误“必须声明一个正文,因为它没有标记为抽象,外部或部分”
public virtual string InsuredStatus
{
get
{
string status;
if (ExpDt > _now)
{
status = "ACTIVE";
return status;
}
if (ExpDt < _now)
{
status = "EXPIRED";
if (status == "EXPIRED" && _insuredHistory.Opertion == "M")
{
return "MERGED";
}
return status;
}
return string.Empty;
}
}
有人可以用我的方式指出错误,并简要解释一下我做错了什么以及为什么会抛出这个错误?
答案 0 :(得分:4)
由于你的get有一个body,C#假设你的setter也需要一个。所以当你添加你的setter时,你需要做的不仅仅是set;
它必须是
set { /* real work here */ }