绝对的新手错误,汇总啊
public class ageDemo
{
//readonly int year2;int year2;
// 提示修补 构造函数的生成
public ageDemo()
{}
// 构造函数定义a
ageDemo(int year2)
{
this.year2 = year2;
}}
修改1行代码解决报错问题.
public int year2;
2 只读
readonly int year2;
主函数
#region MyRegion
ageDemo agedemo = new ageDemo();agedemo.year2 = 11; // 报错如下图
Console.WriteLine(agedemo.year2);
#endregion