日期:2014-05-18  浏览次数:21014 次

新手不懂,求助在线等
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 或 extern E:\C#\对象的引用\对象的引用\Program.cs 25 25 对象的引用
错误 2 “对象的引用.Person.Age.set”必须声明主体,因为它未标记为 abstract 或 extern E:\C#\对象的引用\对象的引用\Program.cs 25 29 对象的引用
怎么解决啊,帮帮我吧 在线等!

------解决方案--------------------
public int Age{ get;set; } 
=>

C# code

 private int _Age; 
        public int Age
        {
            get
            {
                return _Age;
            }
            set
            {
                _Age= value;
            }
        }