// 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 I30 { public static void Main(string[] args) { // objekt initialisering P o = new P{A = 123, B = "ABC" }; Console.WriteLine(o.A + " " + o.B); // collection initialisering List lsti = new List{1, 2, 3}; foreach(int v in lsti) Console.WriteLine(v); // kombineret List

lstp = new List

{new P{A = 123, B = "ABC" }, new P{A = 456, B = "DEF" }}; foreach(P v in lstp) Console.WriteLine(v.A + " " + v.B); } }