using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public interface IReadOnlyList : IEnumerable, System.Collections.ICollection { T this[int Index] { get; } } public class MyList: List, IReadOnlyList { } public partial class Form1 : Form { MyList list = new MyList(); public Form1() { for(int i=0; i<20;++i) list.Add(i); InitializeComponent(); } public IReadOnlyList GetList { get { return list; } } public ReadOnlyCollection GetList2 { get { return list.AsReadOnly(); } } private void button1_Click(object sender, EventArgs e) { IReadOnlyList ro = this.GetList; ro.Add(20); ReadOnlyCollection ro2 = this.GetList2; ro2.Add(20); } } }