【发布时间】:2013-01-15 08:25:16
【问题描述】:
我想写一个接口类,这样使用
public Interface IFunction
property name as string
end interface
public class ModelFunction
implements IFunction
public property name as string
public sub new()
end class
*EDIT(因为是菜鸟而删除了以下句子,感谢@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
有人对此有更好的解决方案吗?或者可以帮助我处理接口类中的属性。在这里阅读了一些关于 stackoverflow 的文章,但没有一篇为我指明了正确的方向。
【问题讨论】:
-
"vb.net 接口中的属性必须是只读或只写" - 真的吗?
-
原始代码中唯一的问题是他在课堂上的属性缺少
Implements IFunction.name,它应该是:public property name as string Implements IFunction.name
标签: vb.net properties interface