Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dictionary<string,object>
- var name="name";
- var obj = new { name = new object(), };
- var lookup = new Dictionary<string,object>();
- if(obj.GetType().Name.StartsWith("<>f__AnonymousType"))
- {
- foreach (var property in obj.GetType().GetProperties())
- {
- lookup[property.Name] = property.GetValue(obj, null);
- }
- }
- else
- {
- lookup[name]=obj;
- }
- Dictionary<string,object>
- var dic = obj.GetType()
- .GetProperties()
- .ToDictionary(p => p.Name, p=> p.GetValue(obj, null));
- var obj = new Dictionary<string, object>()
- {
- { "Name", t.Name },
- { "Value", t.Value }
- };
Add Comment
Please, Sign In to add comment