VB.Net - Syntax
Overloading
Public Class MyClass
Public Sub New(ByVal myVar1 As String,
ByVal myVar2 As String)
Me.New(myVar1)
End Sub
Public Sub New(ByVal myVar1 As String)
End Sub
End Class
Public Class MyClass
Private _internal1 As String
Private _internal2 As String
Private _internal3 As String
Public Sub New(param1 As String)
Me._internal1 = param1
End Sub
Public Sub New(param1 As String, param2 As String)
Me.New(param1)
Me._internal2 = param2
End Sub
Public Sub New(param1 As String, param2 As String, param3 As String)
Me.New(param1, param2)
Me._internal3 = param3
End Sub
End Class
Me
The Me keyword provides a way to refer to the specific instance of a class or structure in which the code is currently executing.
Me behaves like either an object variable or a structure variable referring to the current instance.
Using Me is particularly useful for passing information about the currently executing instance of a class or structure to a procedure in another class, structure, or module.
MyBase
The MyBase keyword behaves like an object variable referring to the base class of the current instance of a class.
MyBase is commonly used to access base class members that are overridden or shadowed in a derived class.
MyBase.New is used to explicitly call a base class constructor from a derived class constructor.
MyClass
The MyClass keyword behaves like an object variable referring to the current instance of a class as originally implemented.
MyClass is similar to Me, but all method calls on it are treated as if the method were NotOverridable.
Class_Initialize
The Class_Initialize event is no longer supported. Use 'Sub New' to initialize a class.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext