C
csharper
I have been puzzled by some lamda expressions like this one at
http://msdn.microsoft.com/en-us/library/bb549288.aspx
int[] amounts = { 5000, 2500, 9000, 8000, 6500, 4000, 1500, 5500 };
IEnumerable<int> query =
amounts.SkipWhile((amount, index) => amount > index * 1000);
foreach (int amount in query)
{
Console.WriteLine(amount);
}
/*
This code produces the following output:
4000
1500
5500
*/
Apparently, for this lamda expression:
(amount, index) => amount > index * 1000
the runtime knows that the parameter "index" is the index of the integer array amounts. But why doesn't the runtime take "amount" as the index of theinteger array amounts? Is "index" pre-defined in the .net framework? Very unlikely. Or is it positionally determined?
Any thoughts? Thanks.
http://msdn.microsoft.com/en-us/library/bb549288.aspx
int[] amounts = { 5000, 2500, 9000, 8000, 6500, 4000, 1500, 5500 };
IEnumerable<int> query =
amounts.SkipWhile((amount, index) => amount > index * 1000);
foreach (int amount in query)
{
Console.WriteLine(amount);
}
/*
This code produces the following output:
4000
1500
5500
*/
Apparently, for this lamda expression:
(amount, index) => amount > index * 1000
the runtime knows that the parameter "index" is the index of the integer array amounts. But why doesn't the runtime take "amount" as the index of theinteger array amounts? Is "index" pre-defined in the .net framework? Very unlikely. Or is it positionally determined?
Any thoughts? Thanks.