Reputation: 183
In my application, I have a List<float[]>
with arrays varying in sizes each time the application runs. I want to find out the index of arrays in that List<float[]>
with length less than or equal to a specified value.
Lets say I have a List [ float[100], float[80], float[101] ]
. Now I want to know the indexes of those arrays whose length is less than or equal to 100.
I can create Loop and Iterate through each element in the list but that way seems too long. Is there any LINQ way possible?
Upvotes: 0
Views: 628
Reputation: 312136
You could use Linq's Select
to get the indexes, and Where
to filter them out:
List<int> indexes = list.Select((arr, ind) => (arr, ind))
.Where(x => x.arr.Length <= 100)
.Select(x => x.ind)
.ToList();
Upvotes: 3