// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections; public class MyData { private string s; public MyData() { s = ""; } public MyData(string s) { this.s = s; } public string S { get { return s; } set { s = value; } } } public class MyCollection : CollectionBase { public MyData this[int index] { get { return (MyData)List[index]; } } public int Add(MyData value) { return List.Add(value); } } class MainClass { public static void Main(string[] args) { MyCollection mycol = new MyCollection(); mycol.Add(new MyData("A")); mycol.Add(new MyData("BB")); mycol.Add(new MyData("CCC")); for(int i = 0; i < mycol.Count; i++) { Console.WriteLine(mycol[i].S); } } }