Last active
May 5, 2017 08:15
-
-
Save wolf99/502a1e1ec0c98d3aacfd9abc1de628a2 to your computer and use it in GitHub Desktop.
C# function to get a Dictionary of the names and values of the properties of a given object
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
using System.Reflection | |
public class Gists | |
{ | |
public Dictionary<string, object> GetDictionaryOfProperties(o As Object) | |
{ | |
Dictionary<string,string> Properties; | |
Properties = (from x in o.GetType().GetProperties() select x).ToDictionary | |
( x => x.Name, x => x.GetGetMethod().Invoke (o, null)); | |
return Properties; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment