Posted by: Sourav | August 10, 2016

Method Overriding and method hiding(Shadow) in VB


Option Strict On
Imports System

Module Module1

Sub Main()
Dim baseobj As base
baseobj = New Derived
baseobj.print()
baseobj.printconst()
Console.ReadLine()
End Sub

End Module

 

Public Class base
Overridable Sub print()
Console.WriteLine(“Hello I am inside base class”)

End Sub
Sub printconst()
Console.WriteLine(“Hello I am inside base class”)

End Sub
End Class

 

Public Class Derived
Inherits base
Overrides Sub print()
Console.WriteLine(“Hello I am inside child class”)

End Sub
Shadows Sub printconst()
Console.WriteLine(“Hello I am inside base class”)

End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: