// 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.Runtime.CompilerServices; namespace ArraysCo { public class Program { public class P { } public class CI : P { private int v; public CI(int v) { this.v = v; } public override string ToString() { return string.Format("CI({0})", v); } } public class CS : P { private string v; public CS(string v) { this.v = v; } public override string ToString() { return string.Format("CS({0})", v); } } public static void Dump(P[] oa) { Console.Write("Array of :", oa.GetType().GetElementType().FullName); foreach (P o in oa) { Console.Write(" {0}", o); } Console.WriteLine(); } public static void Main(string[] args) { CI[] cia = { new CI(123), new CI(456) }; Dump(cia); CS[] csa = { new CS("ABC"), new CS("DEF") }; Dump(csa); } } }