Revision: 41021
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 11, 2011 00:13 by nivlam
Initial Code
public static IDictionary<string, object> ToDictionary(this object data) { BindingFlags publicAttributes = BindingFlags.Public | BindingFlags.Instance; Dictionary<string, object> dictionary = new Dictionary<string, object>(); foreach (PropertyInfo property in data.GetType().GetProperties(publicAttributes)) { if (property.CanRead) dictionary.Add(property.Name, property.GetValue(data, null)); } return dictionary; }
Initial URL
Initial Description
Initial Title
Get IDictionary from anonymous type
Initial Tags
Initial Language
C#