日期:2014-05-20 浏览次数:21029 次
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();
}
}
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();
}
}
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();
}
}
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public new void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public virtual void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public override void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public virtual void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public void F(string arg)
{
Console.WriteLine("\nChildren:{0}",arg);
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
interface IGrandFather
{
void F();
}
abstract class Father:IGrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}