C#
|
VB.net
|
using System;
public class BC
{
public virtual void Method()
{
Console.WriteLine("I'm from Base Class");
}
}
|
Public Class BC
Public Overridable Sub Method()
Console.WriteLine("I'm from Base Class")
End Sub
End Class
|
public class DC : BC
{
public override void Method()
{
Console.WriteLine("I'm from Derived Class");
}
}
|
Public Class DC
Inherits BC
Public Overrides Sub Method()
Console.WriteLine("I'm from Derived Class")
End Sub
End Class
|
class Program
{
static void Main()
{
DC ob = new DC();
ob.Method();
((BC)ob).Method();
Console.ReadKey();
}
}
|
Class Program
Private Shared Sub Main()
Dim ob As New DC()
ob.Method()
DirectCast(ob, BC).Method()
Console.ReadKey()
End Sub
End Class
|
Output:
I'm from Derived Class
I'm from Derived Class
|