Selecting a value from multiple dictionaries inside an enumeration
- by johaanfaust
If I have an enumeration of dictionaries
IEnumerable<IDictionary<string, float>> enumeration
can I perform a Linq query on it so that I can select by a value from each dictionary in the enumeration using the same key?
I can do this in a loop:
float f;
foreach (var dictionary in enumeration)
{
if (dictionary.TryGetValue("some key", out f))
{
Console.WriteLine(f);
}
}
(The eventual plan is to compare the performance of the query verses the equivalent nested looping statements (the enumeration itself is formed from either another query or an equivalent set of loops).)