Saturday, June 7, 2014

In C#, a Count Lambda expression is going to return a total count across records where a criteria is matched.

http://msdn.microsoft.com/en-us/library/bb397687.aspx has a pretty good example of finding odd numbers which will put the value of 5 into a variable called "oddNumbers" in executing.

int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int oddNumbers = numbers.Count(n => n % 2 == 1);

No comments:

Post a Comment