CSharp examples for System.Collections.Generic:IEnumerable
Indexes Of element in IEnumerable
using System.Linq; using System.Collections.Generic; using System;/*from w w w .java 2 s. com*/ public class Main{ public static IEnumerable<int> IndexesOf<T>(this IEnumerable<T> sequence, T item) { if (sequence == null) throw new ArgumentNullException("sequence"); var i = 0; foreach (var e in sequence) { if (Equals(e, item)) yield return i; i++; } } }