Difference Between Select and SelectMany

后端 未结 17 1269
长情又很酷
长情又很酷 2020-11-22 05:21

I\'ve been searching the difference between Select and SelectMany but I haven\'t been able to find a suitable answer. I need to learn the differenc

17条回答
  •  遇见更好的自我
    2020-11-22 05:27

    The SelectMany method knocks down an IEnumerable> into an IEnumerable, like communism, every element is behaved in the same manner(a stupid guy has same rights of a genious one).

    var words = new [] { "a,b,c", "d,e", "f" };
    var splitAndCombine = words.SelectMany(x => x.Split(','));
    // returns { "a", "b", "c", "d", "e", "f" }
    

提交回复
热议问题