Reputation: 11
var traps = new List<trap>();
if(traps.Count(x => x.trapToughness == tough.weak) => 5)
{
//Some Code
}
I don't want the count method to start counting from the beginning of the List.
I have a local variable which holds the index(0,5,10,...)
Upvotes: 0
Views: 89
Reputation: 37299
var traps = new List<trap>();
var counter = traps.Skip(indexVariableToStartFrom)
.Count(x => x.trapToughness == tough.weak);
If(counter >= 5)
{
// Some code
}
Upvotes: 1
Reputation: 1728
The Where
clause includes an index as the second parameter. This is the index of the item in the IEnumerable
var traps = new List<trap>();
if(traps.Where((x, y) => x.trapToughness == tough.weak && y > INDEX)
.Count() >= 5)
{
//Some Code
}
Upvotes: 0