// 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.Generic; using System.Reflection; namespace E { public class Data { public int I { get; set; } public string S { get; set; } public List IL { get; set; } public List SL { get; set; } } public class Program { public static void Dump(object o) { foreach(PropertyInfo pi in o.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { Console.WriteLine(pi.Name); if(pi.PropertyType.IsGenericType) { Console.WriteLine(pi.PropertyType.GetGenericTypeDefinition().FullName); foreach(Type t in pi.PropertyType.GetGenericArguments()) { Console.WriteLine(" " + t.FullName); } } else { Console.WriteLine(pi.PropertyType.FullName); } } } public static void Main(string[] args) { Dump(new Data()); } } }