Find All Index : List « Collections Data Structure « C# / C Sharp
- C# / C Sharp
- Collections Data Structure
- List
Find All Index
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
public static class CollectionsExtensions
{
public static List<int> FindAllIndex<T>(this List<T> container, Predicate<T> match)
{
var items = container.FindAll(match);
List<int> indexes = new List<int>();
foreach (var item in items)
{
indexes.Add(container.IndexOf(item));
}
return indexes;
}
}
Related examples in the same category