// 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 Person { public string FirstName { get; set; } public string LastName { get; set; } public Address Address { get; set; } } public class Address { public string City { get; set; } public int ZipCode { get; set; } } public class Program { public static void Main(string[] args) { Person o = new Person { FirstName = "Oscar", LastName = "Mayer", Address = new Address { City = "Somewhere", ZipCode = 1234 } }; PropertyInfo pi1 = typeof(Person).GetProperty("Address"); PropertyInfo pi2 = typeof(Address).GetProperty("City"); String city = (string)pi2.GetValue(pi1.GetValue(o, null), null); Console.WriteLine(city); } } }