var traps = new List<trap>();
if(traps.Count(x => x.trapToughness == tough.weak) => 5)
{
//Some Code
}我不希望count方法从列表的开头开始计数。
我有一个局部变量,它保存索引(0,5,10,...)
发布于 2016-07-23 04:07:20
var traps = new List<trap>();
var counter = traps.Skip(indexVariableToStartFrom)
.Count(x => x.trapToughness == tough.weak);
If(counter >= 5)
{
// Some code
}发布于 2016-07-23 04:10:24
Where子句包含一个索引作为第二个参数。这是IEnumerable中项目的索引
var traps = new List<trap>();
if(traps.Where((x, y) => x.trapToughness == tough.weak && y > INDEX)
.Count() >= 5)
{
//Some Code
}https://stackoverflow.com/questions/38534435
复制相似问题