有一个 Select 重载,它为序列的每个元素添加一个索引:
Dim Letters = new string() {"a","b","c","d","e"}
Dim IndexedLetters = Letters.Select(function (aLetter, index) new with {.Index = index + 1, .Letter = aLetter})
' For LINQPad users : IndexedLetters.Dump
这个查询可以用查询符号来写吗?
最佳答案
不,不幸的是它不能。您提到的 Select 重载不是 VB.Net(或 C#)编译器将绑定(bind)到查询符号中的 Select 重载之一。如您的示例所示,您必须手写这个。
关于vb.net - 带索引的 Select 重载的查询符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1012552/