将Collection添加到BlockingCollection(add Collection to BlockingCollection)

编程入门 行业动态 更新时间:2024-10-11 07:34:58
Collection添加到BlockingCollection(add Collection to BlockingCollection)

BlockingCollection仅包含添加单个项目的方法。 如果我想添加一个集合怎么办? 我应该只使用“foreach”循环吗?

为什么BlockingCollection不包含添加集合的方法? 我认为这种方法非常有用。

BlockingCollection contains only methods to add individual items. What if I want to add a collection? Should I just use "foreach" loop?

Why BlockingCollection doesn't contain method to add a collection? I think such method can be pretty useful.

最满意答案

ICollection接口和许多BCL列表类型由于某种原因没有AddRange方法,这很烦人。

是的,您需要foreach知道该集合,如果您经常使用它,您可以编写自己的扩展方法。

ICollection interfaces and many of the BCL list-type classes don't have an AddRange method for some reason and it is annoying.

Yes, you'll need to foreach over the collection, you could write you own extension method if you're using it a lot.

更多推荐

本文发布于:2023-08-01 03:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1354181.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Collection   BlockingCollection   add

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!