此示例演示了一个索引 Where 子句,该子句返回名称短于其值的数字。源代码
public void Linq5()
{
string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
var shortDigits = digits.Where((digit, index) => digit.Length < index);
Console.WriteLine("Short digits:");
foreach (var d in shortDigits)
{
Console.WriteLine("The word {0} is shorter than its value.", d);
}
}
现在我的问题是......我们可以用 LINQ 查询格式写这个,比如:
from u in digits where u.Length>index select u;
Here How to get the INDEX value from above Query?