When I want to make a value type read-only outside of my class I do this:
public class myClassInt
{
private int m_i;
public int i {
get { ret
public class MyClassList
{
private List _lst = new List() { 1, 2, 3 };
public IEnumerable ListEnumerator
{
get { return _lst.AsReadOnly(); }
}
}
To check it
MyClassList myClassList = new MyClassList();
var lst= (IList)myClassList.ListEnumerator ;
lst.Add(4); //At this point ypu will get exception Collection is read-only.