Combining List.ForEach and List.Zip I have three lists, and I need to operate on the ith element of each list simultaneously.

private void TripleForEach&lt;T1, T2, T3&gt;(IEnumerable&lt;T1&gt; a1, IEnumerable&lt;T2&gt; a2, IEnumerable&lt;T3&gt; a3, Action&lt;T1, T2, T3&gt; x)
{
    a3.Zip(a2, (t3, t2) =&gt; Tuple.Create(t2, t3)).Zip(a1, (t23, t1) =&gt; Tuple.Create(t1, t23.Item1, t23.Item2)).ToList().ForEach(z =&gt; x(z.Item1, z.Item2, z.Item3));
}


Any better way to do this? Creating and pulling apart those temporary Tuples smells bad to me.
I agree, the temporary tuples are a code smell. They carry a performance overhead, but worse, they obscure the purpose of the code. Here is a way of achieving the goal by working directly on the enumerators.

private static void TripleForEach&lt;TFirst, TSecond, TThird&gt;(
        IEnumerable&lt;TFirst&gt; first,
        IEnumerable&lt;TSecond&gt; second,
        IEnumerable&lt;TThird&gt; third,
        Action&lt;TFirst, TSecond, TThird&gt; action)
{
    using (IEnumerator&lt;TFirst&gt; e1 = first.GetEnumerator())
    using (IEnumerator&lt;TSecond&gt; e2 = second.GetEnumerator())
    using (IEnumerator&lt;TThird&gt; e3 = third.GetEnumerator())
    {
        while (e1.MoveNext() &amp;&amp; e2.MoveNext() &amp;&amp; e3.MoveNext())
        {
            action(e1.Current, e2.Current, e3.Current);
        }
    }
}