标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class A
{
public virtual void Movie()
{
Console.WriteLine("A");
}
}
class B : A
{
public override void Movie()
{
Console.WriteLine("B");
}
}
class C : B
{
public new virtual void Movie()
{
Console.WriteLine("C");
}
}
class D : C
{
public override void Movie()
{
Console.WriteLine("D");
}
}
class Program
{
static void Main(string[] args)
{
A objA = new D();
A objB = new B();
C objC = new D();
A objD = new A();
objA.Movie();
objB.Movie();
objC.Movie();
objD.Movie();
Console.ReadLine();
}
}
}
the reason is like:
B overrides A ,it‘s not virtual.
so the inherited one stops when it can‘t go further or it reach to itself.
标签:
原文地址:http://www.cnblogs.com/itria/p/4378935.html