跳轉到內容

Visual Basic .NET/介面

來自華夏公益教科書,開放的書籍,開放的世界

一個介面是類的公共方法。它們用 Implements 關鍵字宣告。

建立介面

Public Interface Interface1
   Function Function1() As String
End Interface

從類中使用它

Public Class MyClassFromInterface
    implements Interface1()
    ' by pressing enter the IDE creates automatically the implemented interface elements:
    Public Function Function1() As String Implements Interface1.Function1
        ' ...
    End Function
End Class


參考資料

[編輯 | 編輯原始碼]
華夏公益教科書