- John
There is no way to do this (in C#). You are right, the access level
always has to be identical.
The recommended way to get around this is to create methods that get/set
the property with different access levels.
Hope this helps.
--
- Nicholas Paldino [.NET MVP]
- nicholas...@exisconsulting.com
"John Lately" <jo...@dontspamme.com> wrote in message
news:ec%q8.15278$1a.43...@twister.kc.rr.com...
class Foo()
{
private int _number;
public int Number
{
get { return _number; }
}
private void SetNumber(int number)
{
// Perhaps do some validations on number.
_number = number;
}
}
SetNumber isn't a property but allows code in the class to set the Number
property's value.
You could always have the code directly set _number as well, but I like to
create a private method for this even if it is as simple as the one above
(in which case, the C# compiler will inline the code).
-glenn-
"John Lately" <jo...@dontspamme.com> wrote in message
news:ec%q8.15278$1a.43...@twister.kc.rr.com...