Home »

How to achieve Polymorphism in VB.Net?

Question ListCategory: VB.NETHow to achieve Polymorphism in VB.Net?
adamemliy16 author asked 2 years ago
1 Answers
alisataylore190 author answered 11 months ago

We can achieve polymarphism in .Net i.e Compile time polymarphism and Runtime polymarphism. Compiletime Polymarphism achieved by method overloading.

Runtime polymarphism achieved by Early Binding or Late Binding. Provide the function pointer to the object at compile time called as Early Binding.
provide the function pointer to the object at runtime called as Late Binding

class emp having the method display()
class dept having the method display()

create objects as in the main function
// Early binding
dim obj as new emp
dim ob as new dept
obj.display()to call the display method of emp class
ob.displayto call the display method of the dept class

// Late binding
create object in the main class as
object obj
obj=new emp
obj.display()to call the display of emp class
obj=new dept
obj.display()to call the display of dept class

Please login or Register to Submit Answer