.net - How to make a readonly C# List by non declaring its set attribute -
i have list<string> mylist
in class want readonly class users.
list<strign> mylist {get;} private void setlistvalue() { mylist = new list<string>(); mylist.add("ss"); }
like thought set mylist
value inside class in private members , make readonly class users. realised declaring way i'm unable set value.
try:
public list<string> mylist {get; private set;}
this let set inside class, not outside. note not stop external clients updating list, reference it.
Comments
Post a Comment