ADVERTISEMENT
ADVERTISEMENT

VB.Net program to implement an interface in the structure

Here, we are going to learn how to implement an interface in the structure in VB.Net?
Submitted by Nidhi, on December 27, 2020

Here, we will create an interface with method declaration and then implement the interface in the structure using the implements keyword.

Program/Source Code:

The source code to demonstrate the simple interface is given below. The given program is compiled and executed successfully.

'VB.net program to implement an interface in the structure.

Module Module1
    Interface ISample
        Sub Fun()
    End Interface

    Structure Sample
        Implements ISample
        Sub Fun() Implements ISample.Fun
            ' Method Implementation
            Console.WriteLine("Fun() called inside the structure")
        End Sub
    End Structure

    Sub Main()
        Dim S As New Sample()
        S.Fun()
    End Sub
End Module

Output:

Fun() called inside the structure
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1. Here, we created an interface ISample that contains a declaration of the Fun() method. Then we implement the Fun() method in the Sample structure using the implements keyword.

At last, we created a Main() function, which is the entry point for the program, here we created the object of Sample structure and called the fun() method that will print an appropriate message on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

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.