Tutorial by Examples

Classes are vital aspects of OOP. A class is like the "blueprint" of an object. An object has the properties of a class, but the characteristics are not defined within the class itself. As each object can be different, they define their own characteristics. Public Class Person End Class ...
Inherits Specifies the base (or parent) class Public Class Person End Class Public Class Customer Inherits Person End Class 'One line notation Public Class Student : Inherits Person End Class Possible objects: Dim p As New Person Dim c As New Customer Dim s As New Student ...
Overridable Allows a property or method in a class to be overridden in a derived class. Public Class Person Public Overridable Sub DoSomething() Console.WriteLine("Person") End Sub End Class Overrides Overrides an Overridable property or method defined in the base...
The MyBase keyword behaves like an object variable that refers to the base class of the current instance of a class. Public Class Person Public Sub DoSomething() Console.WriteLine("Person") End Sub End Class Public Class Customer Inherits Person Public S...
Me uses the current object instance. MyClass uses the memberdefinition in the class where the member is called Class Person Public Overridable Sub DoSomething() Console.WriteLine("Person") End Sub Public Sub useMe() Me.DoSomething() End Sub ...
Overloading is the creation of more than one procedure, instance constructor, or property in a class with the same name but different argument types. Class Person Overloads Sub Display(ByVal theChar As Char) ' Add code that displays Char data. End Sub Overloads Sub Display...
It redeclares a member that is not overridable. Only calls to the instance will be affected. Code inside the base classes will not be affected by this. Public Class Person Public Sub DoSomething() Console.WriteLine("Person") End Sub Public Sub UseMe() ...
Public Interface IPerson Sub DoSomething() End Interface Public Class Customer Implements IPerson Public Sub DoSomething() Implements IPerson.DoSomething Console.WriteLine("Customer") End Sub End Class

Page 1 of 1