How to append enumerable collection to an existing list in C#

前端 未结 2 851
灰色年华
灰色年华 2021-02-04 01:51

i have three functions which are returning an IEnumerable collection. now i want to combine all these into one List. so, is there any method by which i can append items from IEn

2条回答
  •  佛祖请我去吃肉
    2021-02-04 02:34

    If you already have a list:

    list.AddRange(yourCollectionToAppend);
    

    If you have 2 enumerables and haven't created the list yet:

    firstCollection.Concat(secondCollection).ToList();
    

提交回复
热议问题