新手不懂,求助在线等
using System;
using System.Collections.Generic;
using System.Text;
namespace 对象的引用
{
class Program
{
static void Main(string[] args)
{
int i = 10;
int j = i;
i++;
Console.WriteLine(j);
Person p1 = new Person();
Person p2 = new Person();
p1.Age++;
Console.WriteLine(p2);
Console.ReadKey();
}
}
class Person
{
public int Age{ get;set; }
public Person(int age)
{
this.Age = age;
}
}
}
错误1“对象的引用.Person.Age.get”必须声明主体,因为它未标记为 abstract 或 externE:\C#\对象的引用\对象的引用\Program.cs2525对象的引用
错误2“对象的引用.Person.Age.set”必须声明主体,因为它未标记为 abstract 或 externE:\C#\对象的引用\对象的引用\Program.cs2529对象的引用
怎么解决啊,帮帮我吧 在线等!
[解决办法]
public int Age{ get;set; }
=>
- C# code
private int _Age; public int Age { get { return _Age; } set { _Age= value; } }