Interface in vb.net

Satyapriyanayak
Posted by Satyapriyanayak under VB.NET category on | Points: 40 | Views : 1059
Interface:-It is the specification of class members not the implementation of members. It is the substitute of multiple inheritance i.e more than one interface can be implemented by a single class. The members within the interface are not defined. Variables cannot be declared within the interface. 

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim a As New raj1
a.sagar(25)
a.amit("Abhijeet")
MsgBox(a.rahul(10, 20))

End Sub

Public Interface raj

Sub sagar(ByVal x As Integer)
Sub amit(ByVal s As String)
Function rahul(ByVal x As Integer, ByVal y As Integer)

End Interface

Public Class raj1
Implements raj

Public Sub amit(ByVal s As String) Implements raj.amit

MsgBox("Hello" & s)

End Sub

Public Function rahul(ByVal x As Integer, ByVal y As Integer) As Object Implements raj.rahul

Dim z As Integer
z = x + y
Return z

End Function

Public Sub sagar(ByVal x As Integer) Implements raj.sagar

MsgBox(x)

End Sub

End Class

End Class

Comments or Responses

Login to post response