By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

Property Accessors w/diff Accessibility??

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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.

Nov 21 '05 #2

P: n/a
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!! :)
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
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

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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.


Nov 21 '05 #3

P: n/a
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

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
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!! :)
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:ev**************@TK2MSFTNGP09.phx.gbl...
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

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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.



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.