Selecting a value from multiple dictionaries inside an enumeration
Posted
by johaanfaust
on Stack Overflow
See other posts from Stack Overflow
or by johaanfaust
Published on 2010-06-03T21:28:33Z
Indexed on
2010/06/03
21:34 UTC
Read the original article
Hit count: 192
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).)
© Stack Overflow or respective owner