Flipje,
As Tim suggests, in .NET 2.0 you can have different access levels on
properties.
http://msdn2.microsoft.com/en-us/library/75e8y5dd(en-US,VS.80).aspx
| public int Thingy
| {
| get { return mThingy; }
| private set { mThingy = value; }
| }
In .NET 1.0 & 1.1 I would normally use a readonly property, then create a
Set
| public int Thingy
| {
| get { return mThingy; }
| }
private SetThingy(int value) { ...}
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Flipje" <(E-Mail Removed)> wrote in message
news:4366365c$0$11067$(E-Mail Removed)...
| In my view, there is a major drawback to using attributes: the getter and
| the setter have identical protection levels. But I usually want the getter
| to be public and the setter to be protected or even private.
|
| Example: I would have liked this to be possible:
|
| int Thingy
| {
| public get { return mThingy; }
| private set { mThingy = value; }
| }
|
| Unfortunately, it isn't. So now, instead of attributes, I use good old
| GetThingy () and SetThingy () functions. I've been trying to find a decent
| discussion about the subject, but it seems like I'm the only one who sees
| having identical protection levels as a problem. So, am I missing
something?
| Is there some way to make attributes work the way I want?
|
|
|