Created
June 7, 2016 06:06
-
-
Save cguldogan/5464dcf29ad9757c214af76c78393463 to your computer and use it in GitHub Desktop.
C# Class which returns the properties of an object
This file contains hidden or 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 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