×

VB.Net Programs

VB.Net program to demonstrate the 'MyClass' keyword

By Nidhi Last Updated : November 13, 2024

'MyClass' keyword in VB.Net

Here, we will demonstrate the MyClass keyword. The MyClass keyword is used to refer to the current class name.

Program/Source Code:

The source code to demonstrate the MyClass keyword is given below. The given program is compiled and executed successfully.

VB.Net code to demonstrate the example of 'MyClass' keyword

'VB.net program to demonstrate the "MyClass" keyword.

Module Module1
    Class Sample
        Sub Fun1()
            Console.WriteLine("Fun1() called")
        End Sub

        Sub Fun2()
            MyClass.Fun1()
            Console.WriteLine("Fun2() called")
        End Sub
    End Class

    Sub Main()
        Dim obj As New Sample()

        obj.Fun2()
    End Sub
End Module

Output:

Fun1() called
Fun2() called
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Sample class. In the Sample class, we created the three methods fun1() and fun2(). Here, we called fun1() method inside the fun2() method using the MyClass keyword.

At last, we created the Main() method, the Main() method is the entry point for the program. Here, we created the object of the Sample class and then called the fun2() method that will call the fun1() method and print messages on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.