ConcurrentBag - Add Multiple Items?

后端 未结 5 1883
庸人自扰
庸人自扰 2021-01-01 08:21

Is there a way to add multiple items to ConcurrentBag all at once, instead of one at a time? I don\'t see an AddRange() method on ConcurrentBag, but there is a Concat(). How

5条回答
  •  旧时难觅i
    2021-01-01 09:16

    Concat is an extension method provided by LINQ. It is an immutable operation that returns another IEnumerable that can enumerate the source collection followed immediately by the specified collection. It does not, in any way, change the source collection.

    You will need to add your items to the ConcurrentBag one at a time.

提交回复
热议问题