vb.net - .net 错误 : Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers

标签 vb.net interface

尝试在 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/

相关文章:

vb.net - 如何从设置加载背景图片?

vb.net - Selenium:使用 chrome 驱动程序将文件下载到特定文件夹

vector 中的 C++ 模板类对象

c# - 这是 C# 泛型错误吗?

asp.net - UpdatePanel崩溃,其他更新面板不起作用

mysql - 如何在格式为 MM/dd/yy 的日期上使用 MYSQL

.net - VB.Net 构造函数顺序很重要?

c# - 如何获取网络接口(interface)的状态?

interface - 如何在 Fortran 界面中使用用户定义类型

go - 如何在不更改golang中原始值的情况下修改对象的值副本?