I have a dictionary collection, string, int. I want convert this dictionary to anonymous object with properties that are collection keys and anonymous object propertie's values are dictionary values. Is it a way to do it?
Thank you
I have a dictionary collection, string, int. I want convert this dictionary to anonymous object with properties that are collection keys and anonymous object propertie's values are dictionary values. Is it a way to do it?
Thank you
Are you looking for this?
var keyVals = dict.Select(kv => new { Key = kv.Key, Value = kv.Value });
But i can't imagine a use case for this. Why do you prefer the anonymous type over the already available dictionary?
Like this :
from x in mydictionairy select new { anonymousKey = x.Key, anonymousValue = x.Value}