Polymorphism

Polymorphism is the ability of a class to take on different functionality based on the context in which it is used. Polymorphism is chiefly implemented in most OOP languages using techniques called method overloading, overriding, and shadowing.

Overloading

Overloading is how we can create methods that have the same name but accept many different argument parameters. We can overload methods we create and we can overload methods we override. Suppose we want to create a function that, if passed numbers, adds the two numbers and returns the result, but if passed strings, concatenates the strings and returns the result.

 Public Function Add(ByVal intA As Integer, _ ByVal intB As Integer) as Object Dim intC As Integer intC = intA + intB ...

Get ADO.NET Programming in Visual Basic™ .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.