Jameson wrote:
I have a property defined something like:
Public Property Index As Integer
Get
Return m_Index
End Get
Set (value As Integer )
m_Index = Value
End Set
End Property
I want all classes to be able to access the "Get" (hence public) but
only a few classes to be able to access the "Set". How can I specify
which classes can access Set in this context?
The scope options work like this:
- If you change Set to be Private, only other code within the same class
will be able to access it. Other classes, inside or outside of your
assembly, will not be able to use Set.
- If you change Set to be Friend, all classes within your assembly will be
able to access the Set. Classes outside of your assembly will not be able to
access it.
- If you change Set to be Protected, only your class and other classes that
inherit from your class (even if they themselves are in different
assemblies) will be able to access it. Other classes within your assembly
will not be able to access it, nor will classes from other assemblies
(unless as already noted they inherit from your class).
- If you change Set to be Protected Friend, the same rules apply as
Protected, except that all classes within your assembly will be able to
access it too, regardless of whether or not they inherit from your class.
Does that help you to decide?
--
(O)enone