Last active
December 19, 2015 12:59
-
-
Save AlexArchive/5958825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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