从codebetter上看到的,看看你的基本功
and
结果是次要的 原理是重要的.如果两天之内没人给较好的解释,我将给出,其实在我以前的随笔中有提到.
using System;
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public virtual void Foo()
{
Console.WriteLine("Call on B.Foo()");
}
}
class C : B
{
public override void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public virtual void Foo()
{
Console.WriteLine("Call on B.Foo()");
}
}
class C : B
{
public override void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
using System;
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public override void Foo()
{
Console.WriteLine("Call on B.Foo() " );
}
}
class C : B
{
public new void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public override void Foo()
{
Console.WriteLine("Call on B.Foo() " );
}
}
class C : B
{
public new void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
and
using System;
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public virtual new void Foo()
{
Console.WriteLine("Call on B.Foo() " );
}
}
class C : B
{
public override void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
class A
{
public virtual void Foo()
{
Console.WriteLine("Call on A.Foo()");
}
}
class B : A
{
public virtual new void Foo()
{
Console.WriteLine("Call on B.Foo() " );
}
}
class C : B
{
public override void Foo()
{
Console.WriteLine("Call on C.Foo()");
}
}
class D
{
static void Main()
{
A c1 = new C();
c1.Foo();
Console.ReadLine();
}
}
结果是次要的 原理是重要的.如果两天之内没人给较好的解释,我将给出,其实在我以前的随笔中有提到.