|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Readonly propertyIs there a way in C# for a property to be Write-enabled from a certain
class and readonly from outside classes? For an example, I have two objects User and UserManager. I want certain properties that should be readonly be set by the UserManager. Other classes should only be able to read that property. Such properties include, User.Exists and User.DateCreated etc. vze1r***@verizon.net wrote:
> Is there a way in C# for a property to be Write-enabled from a certain The usual solution here is to use internal visibility for things that> class and readonly from outside classes? need to be writable by classes in the same assembly. For example: ---8<--- class Foo { private int _value; public int Value { get { return _value; } internal set { _value = value; } } } --->8--- -- Barry |
|||||||||||||||||||||||