Is there a way to do foreach
style iteration over parallel enumerables in C#? For subscriptable lists, I know one could use a regular for
loop iterati
If you want to stick to the basics - I rewrote the currently accepted answer in a simpler way:
public static IEnumerable Combine (this IEnumerable> sources)
{
var enums = sources
.Select (s => s.GetEnumerator ())
.ToArray ();
while (enums.All (e => e.MoveNext ())) {
yield return enums.Select (e => e.Current).ToArray ();
}
}
public static IEnumerable Combine (params IEnumerable[] sources)
{
return sources.Combine ();
}