using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace gouzao
{
class Program
{
static void Main(string[] args)
{
Person p = new Person();
Person p1 = new Person("Tom");
Person p2 = new Person(7,"Gino");
Console.WriteLine("name:{0},age:{1}",p.Name,p.Age);
Console.WriteLine("name:{0},age:{1}", p1.Name, p1.Age);
Console.WriteLine("name:{0},age:{1}", p2.Name, p2.Age);
Console.ReadKey();
}
}
class Person
{
private int age;
public string Name { get; set; }
public int Age
{
get
{
return this.age +1 ;
}
set
{
this.age = value;
}
}
public Person()
{
this.Name = "NoName";
this.Age = 11;
}
public Person(string str)
{
this.Name = str;
//这里的Age默认是0
}
public Person(int age, string name)
{
this.Age = age;
this.Name = name;
}
}
}