I want to return all of the indices from an array where a condition is met. I’ve come up with
myarray
.Select((p,i) =>
{
if (SomeCondition(p)) return i;
else return -1;
})
.Where(p => p != -1);
I know I can write an extension method or do it with a loop, but I was wondering if there was something built into LINQ that I’m unfamiliar with. Apologies if this is trivial
Personally, I’d go with this: