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

int divisor = AllMyControls.Where(p => p.IsActiveUserControlChecked).Count()

or simply

int divisor = AllMyControls.Count(p => p.IsActiveUserControlChecked);

Since you are a beginner, it would be worthwhile to take a look at Enumerable documentation

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)