using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;
public static void Main()
var thing = new PropertiesFun(){StringThing = "Testing"} ;
var test = new Destination(){Address = "testing"};
PropertiesFun[] testArray = new PropertiesFun[] { new PropertiesFun(){StringThing = "Testing"} };
test.testArray = testArray;
Type objType = testArray.GetType();
Console.WriteLine(objType);
PropertyInfo[] properties = objType.GetProperties();
object propValue = properties[3].GetValue(testArray, null);
Console.WriteLine(propValue);
var elems = propValue as IList;
Console.WriteLine("hit");
Console.WriteLine(elems);
foreach (PropertyInfo property in properties)
if (property.PropertyType.Assembly == objType.Assembly)
PrintProperties(test, 0);
public static void PrintProperties(object obj, int indent)
string indentString = new string(' ', indent);
Type objType = obj.GetType();
PropertyInfo[] properties = objType.GetProperties();
foreach (PropertyInfo property in properties)
Console.WriteLine("Prop: " + property);
object propValue = property.GetValue(obj, null);
var elems = propValue as IList;
foreach (var item in elems)
PrintProperties(item, indent + 3);
if (property.PropertyType.Assembly == objType.Assembly)
Console.WriteLine("{0}{1}:", indentString, property.Name);
PrintProperties(propValue, indent + 2);
Console.WriteLine("{0}{1}: {2}", indentString, property.Name, propValue);
private static void Dump(object o)
{ public string Address { get; set; }
public DateTime LicenseExpiration { get; set; }
public string Fax { get; set; }
public Guid Id { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Type { get; set; }
public PropertiesFun[] testArray {get; set; }
public class PropertiesFun
private string stringThing;
public string StringThing
return stringThing ?? GetStringThing();
private string GetStringThing()