尝试在 vb.net 中实现接口(interface)时出现此错误:
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
什么不见了?
最佳答案
您需要告诉代码 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# 那样支持隐式接口(interface)实现。
关于vb.net - .net 错误 : Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5249726/