How to merge a collection of collections in Linq

后端 未结 2 1379
野的像风
野的像风 2021-02-05 00:03

I would like to be able to fusion an IEnumerable> into IEnumerable (i.e. merge all individual collections into one)

2条回答
  •  误落风尘
    2021-02-05 00:13

    var lists = GetTheNestedCase();
    return
        from list in lists
        from element in list
        select element;
    

    is another way of doing this using C# 3.0 query expression syntax.

提交回复
热议问题