.NET名单< T> CONCAT VS的AddRange名单、LT、NET、GT

由网友(香蕉你个麻辣)分享简介:这是一个泛型列表中的AddRange和Concat的功能之间的区别是什么?一个建议比其他?What is the difference between the AddRange and Concat functions on a generic List? Is one recommended over the ot...

这是一个泛型列表中的AddRange和Concat的功能之间的区别是什么?一个建议比其他?

What is the difference between the AddRange and Concat functions on a generic List? Is one recommended over the other?

推荐答案

他们有完全不同的语义。

They have totally different semantics.

的AddRange通过添加其他项目将其修改列表中。

AddRange modifies the list by adding the other items to it.

的毗连返回包含列表和其他项目的新序列,而不修改列表。

Concat returns a new sequence containing the list and the other items, without modifying the list.

选择哪一个有你想要的语义。

Choose whichever one has the semantics you want.

阅读全文

相关推荐

最新文章