Here is a code snippet that uses a little reflection to return a string representing all of the various fields and properties contained in the given object, and their related values. Because it uses reflection it has a higher cost at runtime than typical strongly-typed code ... but there are still some scenarios this type of discovery is useful.
public static string GetObjectDump(Object thisObject)
{
StringBuilder sb = new StringBuilder();
Type thisType = thisObject.GetType();
var fields = thisType.GetFields();
foreach (var f in fields)
sb.Append(String.Format("{0} = {1}", f.Name, f.GetValue(thisObject)) + Environment.NewLine);
var properties = thisType.GetProperties();
foreach (var p in properties)
sb.Append(String.Format("{0} = {1}", p.Name, p.GetValue(thisObject, null)) + Environment.NewLine);
return sb.ToString();
}