Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从列表中的偶数位置选择仅使用 Linq 的条目?
您可以使用 Enumerable.Where 的重载,其中谓词包含项目的索引。
var myList = new List<int>{ 1, 2, 3, 4, 5, 6 }; var evenIndexes = myList.Where( (num, index) => index % 2 == 0);