日期:2014-05-18  浏览次数:20822 次

可不可以达到这种效果,继承相关问题
class a
{
  public void show(){console.write("this is ")}
}
class b:a
{
  public void show(){console.write("a demo")}
}
输出结果
this is a demo

可以么?

------解决方案--------------------
C# code


class A
{
  public virtual void Show(){ Console.Write("this is "); }
}

class B:A
{
  public override void Show(){
     base.Show();
     Console.Write("a demo");

  }
}

------解决方案--------------------
一楼正解!
------解决方案--------------------
探讨

C# code


class A
{
public virtual void Show(){ Console.Write("this is "); }
}

class B:A
{
public override void Show(){
base.Show();
Console.Write("a demo");

}
}

------解决方案--------------------
探讨

引用:

C# code


class A
{
public virtual void Show(){ Console.Write("this is "); }
}

class B:A
{
public override void Show(){
base.Show();
Console.Write("a demo");

}
}

+……