例如,Visual Basic允许具有混合访问级别的属性 Public Property Name() as String Get End Get Friend Set(ByVal value As String) End SetEnd Property 有没有办法用混合的getter / setter访问级别定义MustOverride属性? 嗯
Public Property Name() as String Get End Get Friend Set(ByVal value As String) End Set End Property
有没有办法用混合的getter / setter访问级别定义MustOverride属性?
嗯……你可以很容易地在C#中:public abstract string Foo { get; protected set; }
不幸的是,当我反编译时,Reflector会创建无效的VB …
编辑:看了几个文档,我怀疑你不能这样做:( MustOverride documentation声明:
Incomplete Declaration. When you
specify MustOverride, you do not
supply any additional lines of code
for the property or procedure, not
even the End Function, End Property,
or End Sub statement.
这告诉我你不能指定不同的访问级别:(