Hi
How to add a ReadOnly property in C#.NET?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 12, 2012, 8:21 AM
int _myInt
public int MyProperty { get { return _myInt; } }
This is because 'auto-implemented' properties must have both a getter and setter even though the access modifier can differ for the two.
Amit PatelPosted Sep 12, 2012, 6:54 AM
public int MyProperty { get; private set; }
And
public int MyProperty { get; }