C#
|
VB.net
|
using System;
public class ParentBC
{
public ParentBC()
{
Console.WriteLine("1. I'm from Parent Constructor");
}
public void parentMethod()
{
Console.WriteLine("2. I'm from Parent Method");
}
}
|
Public Class ParentBC
Public Sub New()
Console.WriteLine("1. I'm from Parent Constructor")
End Sub
Public Sub parentMethod()
Console.WriteLine("2. I'm from Parent Method")
End Sub
End Class
|
public class ChildDC : ParentBC
{
public ChildDC()
{
Console.WriteLine("3. I'm from Child Constructor");
}
public void childMethod()
{
Console.WriteLine("4. I'm from Child Method");
}
}
|
Public Class ChildDC
Inherits ParentBC
Public Sub New()
Console.WriteLine("3. I'm from Child Constructor")
End Sub
Public Sub childMethod()
Console.WriteLine("4. I'm from Child Method")
End Sub
End Class
|
class Program
{
public static void Main()
{
ChildDC c = new ChildDC();
c.parentMethod();
c.childMethod();
Console.ReadLine();
}
}
|
Class Program
Public Shared Sub Main()
Dim c As New ChildDC()
c.parentMethod()
c.childMethod()
Console.ReadLine()
End Sub
End Class
|
Output:
1. I'm from Parent Constructor
3. I'm from Child Constructor
2. I'm from Parent Method
4. I'm from Child Method
|