加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

接口VB.NET中的读写属性

发布时间:2020-12-17 00:32:30 所属栏目:大数据 来源:网络整理
导读:我想编写一个接口类并像这样使用它 public Interface IFunction property name as stringend interfacepublic class ModelFunction implements IFunction public property name as string public sub new()end class *编辑(删除后面的句子为noob,感谢@damien
我想编写一个接口类并像这样使用它
public Interface IFunction
  property name as string
end interface

public class ModelFunction
   implements IFunction

  public property name as string

  public sub new()

end class

*编辑(删除后面的句子为noob,感谢@damien_the_unbeliever指出这一点):但这是不可能得到的,因为vb.net接口中的属性必须是只读或只写(据我所知)*

我现在写了这个,但似乎有点不对劲:

public Interface IFunction
  Readlonly property getName() as string
  writeonly property writeName() as string
end interface

public class ModelFunction
 implements IFunction

 ....
end class

有人有更好的解决方案吗?或者可以帮助我使用Interface类中的属性.已经在stackoverflow上阅读了一些文章,但没有一篇指出我正确的方向.

这对我来说很好:
Public Class Class1
    Implements Thing

    Property Gary As Int32 Implements Thing.Gary
        Get
            Return 10
        End Get
        Set(value As Int32)

        End Set
    End Property
End Class

Public Interface Thing
    Property Gary As Int32
End Interface

Interface的文档页面上甚至有一个例子:

Interface IAsset
    Event ComittedChange(ByVal Success As Boolean)
    Property Division() As String 
    Function GetID() As Integer 
End Interface

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读