Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's Wrong With this?
Message
From
07/06/2010 14:14:53
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01467696
Message ID:
01467711
Views:
71
>>>First I'm creating a dictionary like this:
>>>
>>>
>>>Dictionary<int, bool> lRuleCheck = new Dictionary<int, bool> { };
>>>
>>>
>>>The dictionary is being populated with PK's and True/False. Then, I later query it like this:
>>>
>>>
>>>var trueCount = lRuleCheck.Select(x => x.Value == true).Count();
>>>var falseCount = lRuleCheck.Select(x => x.Value == false).Count();
>>>
>>>
>>>At the point this is run, there's only one item in the dictionary, with a 0/true, yet both trueCount and falseCount are both 1.
>>
>>Try:
var trueCount = lRuleCheck.Where(x => x.Value).Count();
>>var falseCount = lRuleCheck.Where(x => !x.Value).Count();
>
>
>That did it. Thanks!

What's the difference? Or lucky guess?
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform