首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

新手不懂

2012-08-17 
新手不懂,求助在线等using Systemusing System.Collections.Genericusing System.Textnamespace 对象的

新手不懂,求助在线等
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;            }        } 

热点排行