using System;
/// <summary>
/// Summary description for Class1
/// </summary>
interface I
{
void dis();
}
class B:I
{
public virtual void dis()
{
Console.WriteLine("dis() in Base");
}
}
class D : B
{
public override void dis()
{
Console.WriteLine("dis() in Derived");
}
}
class c2
{
public static void Main()
{
D d = new D();
d.dis();
I i = (I)d;// calls Base version even though D hv a fun of the correct form.Bcoz D doesn't implement interface.
i.dis();
}
}
output:
C:\workcode\C#>c2.exe
dis() in Derived
dis() in Derived
C:\workcode\C#>
It should give o/p:
C:\workcode\C#>c2.exe
dis() in Derived
dis() in Base
C:\workcode\C#>