I generally override the ToString() method to output the property names and the values associated to them. I got a bit tired of writing these by hand so I\'m looking for a d
I ran into this myself where I am looking for an option to serialize into something readable. If there are no read only properties xml serialization can give a readable string. However if there are read only properties / fields then xml serialization is not an option.
public static string ToString(object serializeable)
{
var type = serializeable.GetType();
try
{
var sw = new StringWriter();
new XmlSerializer(type).Serialize(sw, serializeable);
return sw.ToString();
}
catch
{
return type.FullName;
}
}