How do I merge (or zip) two IEnumerables together?

前端 未结 10 1597
予麋鹿
予麋鹿 2020-12-17 00:38

I have an IEnumerable and an IEnumerable that I want merged into an IEnumerable> where

10条回答
  •  伪装坚强ぢ
    2020-12-17 00:57

    As a update to anyone stumbling across this question, .Net 4.0 supports this natively as ex from MS:

    int[] numbers = { 1, 2, 3, 4 };
    string[] words = { "one", "two", "three" };
    
    var numbersAndWords = numbers.Zip(words, (first, second) => first + " " + second);
    

提交回复
热议问题