Zip N IEnumerables together? Iterate over them simultaneously?

前端 未结 6 1593
春和景丽
春和景丽 2020-12-06 18:57

I have:-

IEnumerable> items;

and I\'d like to create:-

IEnumerable> r         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 19:25

    Here's one that is a bit shorter, but no doubt less efficient:

    Enumerable.Range(0,items.Select(x => x.Count()).Max())
        .Select(x => items.SelectMany(y => y.Skip(x).Take(1)));
    

提交回复
热议问题