Home >>VB.Net Built-in Functions >VB.Net program of the simple interface

VB.Net program of the simple interface

Write a VB.Net program of the simple interface

Here, we can build a method declaration interface and then use the implement keyword to implement the interface in the class.

Program :

Below is the source code to demonstrate the basic interface. The program given is compiled and successfully executed.

'VB.net 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

We created a Module1 module in the program above. Here, we built an ISample interface that contains the Fun() method declaration. In the Sample class, we then use the implementation keyword to implement the Fun() method.

Finally, we created a Main() function, which is the program entry point, here we created the Sample class object and named the fun() method, which will print a suitable message on the console screen.

No Sidebar ads