/ Published in: C#

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static IDictionary<string, object> ToDictionary(this object data) { BindingFlags publicAttributes = BindingFlags.Public | BindingFlags.Instance; foreach (PropertyInfo property in data.GetType().GetProperties(publicAttributes)) { if (property.CanRead) dictionary.Add(property.Name, property.GetValue(data, null)); } return dictionary; }
Comments
