如何在C#中创建一个子类的实例?儿童班的实例?
public class Parent
{
public virtual void test()
{
Console.WriteLine("this is parent");
}
}
public class Child : Parent
{
public override void test()
{
Console.WriteLine("this is from child");
}
}
public static void main()
{
//Which one is right below?
Child ch = new Child();
Parent pa = new Parent();
ch = new Parent();
pa = new Child();
ch.test();
pa.test();
}
请加价的代码! – Foole 2010-02-17 11:38:44
^^^酷,T先生评论! ;-) – 2010-02-17 11:39:32