我想编写一个接口类并像这样使用它
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上阅读了一些文章,但没有一篇指出我正确的方向.
这对我来说很好:
原文链接:https://www.f2er.com/vb/255023.htmlPublic 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 IAsset Event ComittedChange(ByVal Success As Boolean) Property Division() As String Function GetID() As Integer End Interface