473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Property Accessors w/diff Accessibility??

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
3 1007
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cody | last post by:
Does the clr allow more than one set and one get method for a property? Is it possible to use overloading for example set_Color(int c), set_Color(Color c)? from msdn: ...
10
by: crjunk | last post by:
I have a script that I want to run only when my input box IS NOT disabled. Can someone tell me if something is wrong with my script? Is "disabled" the correct property to use? function...
13
by: Peter Kirk | last post by:
Hi there, can someone tell me what exactly a "property" is in a C# class? As far as I can see it is "two methods" - ie a getter and a setter for an instance variable. What is the difference...
11
by: wASP | last post by:
Hi, I've got a pair of int properties in a class. The properties in question are indexing values - but that's not relevant to my problem - or it's just symptomatic ... sort of. They are...
62
by: djake | last post by:
Someone can explain me why to use property get and property set to access a value in a class, insted of access the value directly? What's the usefulness of property statements in VB.NET? Thanks
37
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
2
by: Ben Voigt | last post by:
The C# Language Specification says: A virtual property declaration specifies that the accessors of the property are virtual. The virtual modifier applies to both accessors of a read-write...
19
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string?...
2
by: Tony Johansson | last post by:
Hello! I just wonder what this mean it is written in a book called "Visual C# 2005" " The accessibilities that are permitted for accessors depends on the accessibility of the property, and it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.