ーーーーVB.net でのインターフェイスの使い方ーーーー
Module Module1
Sub Main()
Dim hito(2) As hito
hito(0) = New inaba()
hito(1) = New ichikawa()
Console.WriteLine(hito(1).getName)
hito(0).MsgName()
End Sub
End Module
Public Interface hito
Sub MsgName()
Function getName() As String
End Interface
Public Class inaba : Implements hito
Const name As String = "inabaです"
Sub Msgname() Implements hito.MsgName
MsgBox(name)
End Sub
Function getName() As String Implements hito.getName
Return name
End Function
End Class
Public Class ichikawa : Implements hito
Const name As String = "ichikawaです"
Sub Msgname() Implements hito.MsgName
MsgBox(name)
End Sub
Function getName() As String Implements hito.getName
Return name
End Function
End Class
ーーーーオーバーロードも可能ーーーー
Class a
Public Sub test(ByVal a As Integer)
MsgBox(a)
End Sub
Public Sub test(ByVal a As String)
MsgBox(a)
End Sub
Public Function test2(ByVal a As Int32) As String
Return a.ToString
End Function
Public Function test2(ByVal a As String) As String
Return a
End Function
End Class