如下代码,为什么定义 int sum=math+english;时会出错,而把此语句写在Show()方法中却可行
class Person
{
int math;
public int Math
{
get { return math; }
set { math = value; }
}
int english;
public int English
{
get { return english; }
set { english = value; }
}
int sum = math + english;
public void Show()
{
Console.WriteLine("总成绩为:{0}",sum);
}
} |
|