How can I expose a List
so that it is readonly, but can be set privately?
This doesn\'t work:
public List myList
In the .NET 4.5 framework you can expose only the IReadOnlyList interface. Something like:
private List _mylist;
public IReadOnlyList myList { get {return _myList;} }
or if you want to prevent unwanted casting to IList
private List _mylist;
public IReadOnlyList myList { get {return new List(_myList);} }