The following code gives digits whose name is shorter than their value. I can’t understand how LINQ understands that index should be the array index of element. Can somebody explain me…
string[] digits = { "zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine" };
var shortDigits = digits.Where((digit, index) => digit.Length < index);
It’s calling the overload which takes a predicate which is given the value and the index, always. That’s the whole purpose of that overload.
From the docs for the
predicateparameter: