// 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.Reflection; namespace E { public class Program { public static object DefaultValue1() { return default(T); } public static object DefaultValue2(Type t) { return Activator.CreateInstance(t); } public static void Main(string[] args) { Console.WriteLine(DefaultValue1()); Console.WriteLine(DefaultValue1()); Console.WriteLine(DefaultValue1()); Console.WriteLine(DefaultValue2(typeof(int))); Console.WriteLine(DefaultValue2(typeof(double))); Console.WriteLine(DefaultValue2(typeof(bool))); } } }