I want to get my hands dirty with Linq, so I watched a few videos from
www.asp.net, and then turned to
http://msdn2.microsoft.com/en-us/library/bb397687.aspx
for some introduction about the new lamda feature of C#.
In the article linked above, there is an example reproduced here:
int[] numbers = {5,4,1,3,9,8,6,7,2,0 };
int oddNumbers = numbers.Count(n =n % 2 == 1);
I gave it a test, and oddNumbers has a value of 5.
I am confused by the 2nd line, i.e.,
int oddNumbers = numbers.Count(n =n % 2 == 1);
The Count method, as the MSDN doc says, returns the number of elements
in a sequence. So, does
n =n % 2 == 1
return a sequence? How does this happen?
Please shed some light. Thank you.