个人理解 是想这样吗?
public class Father
{
//成员变量
protected string firstName;
protected int wealth;
protected char blood;
//构造函数
public Father(string _firstName, int _wealth, char _blood)
{
this.firstName = _firstName;
this.wealth = _wealth;
this.blood = _blood;
}
}
//子类 继承
public class Son : Father
{
//子类成员变量
public string PlayGame;
//调用父类构造函数
public Son(string _firstName, int _wealth, char _blood, string _PlayGame) :
base(_firstName,_wealth,_blood)
{
this.PlayGame = _PlayGame;
}
public void aa() //方法
{
Console.WriteLine("我姓{0},财产有{1}元,血型是{2},我会玩{3}",this.firstName,this.wealth,this.blood,this.PlayGame);
}
}
class Program
{
static void Main(string[] args)
{
Son son = new Son("史",0,'a',"连连看");//创建子类对象
son.aa();//调用方法
Console.ReadKey();
}
} |