日期:2014-05-18 浏览次数:21005 次
public class Parent
{
public string name { get; private set; }
public int age { get; private set; }
public Parent(string name, int age)
{
this.name = name;
this.age = age;
}
public void ModifyAge(int age)
{
this.age = age;
}
}
public class Child : Parent
{
public int Score { get; private set; }
public Child(string name, int age, int score)
: base(name, age)
{
this.Score = score;
}
public static void Print(Child c)
{
Console.WriteLine("This static method write : " + c.Score);
}
}
static void Main(string[] args)
{
Parent p = new Child("lijian", 27, 90);
Child c = (Child)p;
Child.Print(c);
Console.ReadLine();
}