Skip to content

Instantly share code, notes, and snippets.

@cguldogan
Created June 7, 2016 06:06
Show Gist options
  • Save cguldogan/5464dcf29ad9757c214af76c78393463 to your computer and use it in GitHub Desktop.
Save cguldogan/5464dcf29ad9757c214af76c78393463 to your computer and use it in GitHub Desktop.
C# Class which returns the properties of an object
public static class PrintAllProperties
{
public static string PropertyList(this object obj)
{
var props = obj.GetType().GetProperties();
var sb = new System.Text.StringBuilder();
foreach (var p in props)
{
sb.AppendLine(p.Name + ": " + p.GetValue(obj, null));
}
return sb.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment