aravind Gosh

aravind Gosh

  • NA
  • 3
  • 2.1k

Help with this Lamda Expression

Jan 11 2011 3:52 AM

Hi,
I am learning Lamda Expressions and I find it hard to understand the below expression.  Can some one please explain.  I took it from msdn.
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var firstSmallNumbers = numbers.TakeWhile((n, index) => n >= index);
As per my understanding the above expression is trying to get all the numbers whose value >= its position.  So the output should be(values): 5,4,3,9,8,7 and index(0,1,3,4,5,6,7)
But the original output is 5,4
 
Appreicate your help.
Thanks.
Aravind
 

Answers (3)