How to add a range of items to an IList?

后端 未结 5 627
忘了有多久
忘了有多久 2021-02-04 23:23

There is no AddRange() method for IList.

How can I add a list of items to an IList without iterating through the

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 23:26

    You could do something like this:

    IList oIList1 = new List{"1","2","3"};
    IList oIList2 = new List{"4","5","6"};
    IList oIList3 = oIList1.Concat(oIList2).ToList();
    

    So, basically you would use the Concat() extension and ToList() to get a similar functionality as AddRange().

    Source

提交回复
热议问题