namespace 构造函数
{
class Program
{
static void Main(string[] args)
{
person p1=new person("zs",18,"nan",80);
p1.SayHello();
Console.ReadKey();
}
}
class person
{
public person(string name, int age, string sex)//重载
{
this.name = name;
this.age = age;
this.sex = sex;
}
public person(string name, int age, string sex, int en)
{
this.name = name;
this.age = age;
this.sex = sex;
this.en = en;
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
private int en;
public int En
{
get { return en; }
set { en = value; }
}
public void SayHello()
{
Console.WriteLine("我叫{0},今年{1},我是{2}的,我的英语成绩{3}", this.name, this.age, this.sex, this.en);
}
}
}