本文介绍了.NET名单< T> CONCAT VS的AddRange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个泛型列表中的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.

这篇关于.NET名单< T> CONCAT VS的AddRange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:35