0
下無法編譯:爲什麼我不能在VB.NET中爲「friend」屬性指定一個「protected」修飾符?
MustInherit Class Foo
Friend Property objects As List(Of Object)
Get
Return _objects
End Get
Protected Set(value As List(Of Object))
_objects = value
End Set
End Property
Private Property _objects As New List(Of Object)
End Class
我收到錯誤消息:Access modifier 'Protected Friend' is not valid. The access modifier of 'Get' and 'Set' should be more restrictive than the property access level.
。那麼,這是更嚴格的。 Foo
的子類只能在同一個程序集中設置此屬性。
爲什麼不允許?
很好的答案。我只聲明'_objects'受保護,'objects'爲'ReadOnly','Foo'爲'Friend'。 – 2015-03-02 23:45:40