既然是只读,那只能直接给它赋值了。如果你还要用表达式改,就要可读写。
set
{
sumScore = value;MathScore + EnglishScore + PhysicScore;
}
main:
sumScore = MathScore + EnglishScore + PhysicScore;
很简单
private int sumScore;
public int SumScore
{
get
{
sumScore = MathScore + EnglishScore + PhysicScore;
return sumScore;
}
}
只读了,还能赋值啊,你这是逻辑错误