Property Accessors w/diff Accessibility??

  • Thread starter Thread starter A Traveler
  • Start date Start date
A

A Traveler

Hello,

I am wondering if this is possible: Code myself a nice class, say MyClass.
Give it some property, say MyProp which has Public Readonly but Protected
Write-ability. So it would be, in effect, something like this:

Public Property MyProp() As Whatever
Public Get
Return pMyProp
End Get
Protected Set(Value As Whatever)
pMyProp = Value
End Set
End Property

I know this syntax is not valid, because ive tried it. Is there any way that
this CAN be coded though? Of course it could be worked around by making the
property Public ReadOnly, and then making a Protected Sub SetMyProp(Value As
Whatever). Im just more curious though, if there is anyway to change the
accessiblity scope on the Get and Set portions of a property.

- Arthur Dent.
 
In VS 2005 you can do this. But you cannot alter get AND set modifiers
together, it has to be one or the other

Private pMyProp As Integer

Public Property MyProp() As Integer

Private Get

Return pMyProp

End Get

Set(ByVal Value As Integer)

pMyProp = Value

End Set

End Property


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Cool, Thanks! I sure hope 2005 doesnt get pushed back anymore though... too
many highly anticipated features. If i had to wait much more, i think id go
mad!! :)
 
LOL, I'm mad already and I've got Beta1 of VS2005 ;-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Back
Top