ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the shared methods

Here, we are going to demonstrate the shared methods in VB.Net.
Submitted by Nidhi, on December 28, 2020

Here, we will create a class Sample with shared methods. Shared methods are class methods there is no need to create the object to call shared methods.

Program/Source Code:

The source code to demonstrate the shared methods is given below. The given program is compiled and executed successfully.

'VB.net program to demonstrate the Shared methods.

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

    Sub Main()
        Sample.Fun1()
        Sample.Fun2()
    End Sub
End Module

Output:

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

Explanation:

In the above program, we created a module Module1 that contains a class Sample. In the Sample class, we created two shared methods fun1() and fun2(). To call the shared methods we are not required to create an object.

At last, we created a Main() function, which is the entry point for the program, here we called both shared method that will print the appropriate message 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.