尝试在vb.net中实现接口时出现此错误:
Public Interface IFoo
ReadOnly Property Foo() As String
End Interface
Public Class myFoo
Implements IFoo
Public ReadOnly Property Foo() As String
Get
return "Foo"
End Get
End Property
...
End Class
缺少什么?
答案 0 :(得分:20)
您需要告诉代码myFoo.Foo
实现IFoo.Foo
(注意添加的Implements IFoo.Foo
):
Public Interface IFoo
ReadOnly Property Foo() As String
End Interface
Public Class myFoo
Implements IFoo
Public ReadOnly Property Foo() As String Implements IFoo.Foo
Get
Return "Foo"
End Get
End Property
End Class
据我所知,VB.NET不支持隐式接口实现,就像C#一样。