// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Collections.Generic; public class MyData { private string s; public MyData() : this("") { } public MyData(string s) { this.s = s; } public override string ToString() { return s; } public string S { get { return s; } set { s = value; } } } class TypSafCol2 { public static void Main(string[] args) { List mycol = new List(); 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]); } } }