在下面的例子中如何index
获得它的价值?我知道 n 是从 source 自动获得的numbers
,但是,虽然含义很清楚,但我看不到 index 是如何赋予其值的:
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var firstSmallNumbers = numbers.TakeWhile((n, index) => n >= index);
的签名TakeWhile
是:
public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate);