Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Last active December 19, 2015 12:59
Show Gist options
  • Save AlexArchive/5958825 to your computer and use it in GitHub Desktop.
Save AlexArchive/5958825 to your computer and use it in GitHub Desktop.
public static class DebuggingExtensions
{
public static string ToStringAutomatic<T>(this T obj)
{
const string Seperator = ", ";
const BindingFlags BindingFlags = BindingFlags.Instance | BindingFlags.Public;
var objProperties =
from property in obj.GetType().GetProperties(BindingFlags)
where property.CanRead
select string.Format("{0} : {1}", property.Name, property.GetValue(obj, null));
return string.Join(Seperator, objProperties);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment