VB.Net program to demonstrate the simple interface

Here, we are going to demonstrate the simple interface 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 class 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.

' program to demonstrate the simple interface.

Module Module1
    Interface ISample
        Sub Fun()
    End Interface

    Class Sample
        Implements ISample
        Sub Fun() Implements ISample.Fun
            ' Method Implementation
            Console.WriteLine("Fun() called")
        End Sub
    End Class

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


Fun() called
Press any key to continue . . .


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 class 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 class and called the fun() method that will print an appropriate message on the console screen.

VB.Net Basic Programs »



Comments and Discussions



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

© some rights reserved.