interface ISkill
{
void apply();
}
class Base,ISkill
{
protected void show()
{
Console.WriteLine("base show");
}
public vitual void apply()
{
show();
}
}
class Child : Base
{
public override void apply()
{
base.apply();
Console.WriteLine("child apply");
}
}
//////////////////////////////////////
public interface ISkill
{
void apply();
}
public class Base {
protected void show()
{
Console.WriteLine("base show");
}
}
public class Child : Base, ISkill
{
public void apply()
{
show();
Console.WriteLine("child apply");
}
}
大体写的具体具体还需要自己理解,打码不容易望采纳谢谢
软糖特地测试了下,加一句话base.show()不就行了。
class Program {
static void Main(string[] args) {
ISkill s = new Child();
s.apply();
Console.ReadLine();
}
}
interface ISkill {
void apply();
}
class Base {
protected void show() {
Console.WriteLine("base show");
}
}
class Child : Base, ISkill {
public void apply() {
//这里自动调用show,有什么办法实现吗
//答:直接加下面这句话
base.show();
Console.WriteLine("child apply");
}
}