Saturday 15 September 2012

c# - How to count the number of elements that match a condition with LINQ -


I have tried a lot of things but the most logical one seems to me:

 < Code> int divisor = AllMyControls.Take (p = & gt; p.IsActiveUserControlChecked == true) .ount ();   

AllMyControls is a collection of UserControls , what do I need to know is how many UserControls is IActive User Control Checker The property is set to True.

Tell me VS What is found in:

  The expression of Lambda can not be converted into 'int' because it is not a representative type   

what is in my expression That's wrong?

  int divisor = allmailontols Where (P = & gt; PIsactive User Control Checker) .count ()   

or simply

  int divisor = all macintrol.count (p = & Gt; PISEactive User Control Chucker);   

Since you are getting started, the documentation will be worth noting

No comments:

Post a Comment