ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the 'MyClass' keyword

Here, we are going to demonstrate the 'MyClass' keyword in VB.Net.
Submitted by Nidhi, on December 29, 2020

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 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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.