相关疑难解决方法(0)

如何在C#中连接列表?

如果我有:

List<string> myList1;
List<string> myList2;

myList1 = getMeAList();
// Checked myList1, it contains 4 strings

myList2 = getMeAnotherList();
// Checked myList2, it contains 6 strings

myList1.Concat(myList2);
// Checked mylist1, it contains 4 strings... why?
Run Code Online (Sandbox Code Playgroud)

我在Visual Studio 2008中运行与此类似的代码,并在每次执行后设置断点.之后myList1 = getMeAList();,myList1包含四个字符串,我按下加号按钮以确保它们不是全部为空.

之后 myList2 = getMeAnotherList();,myList2包含六个字符串,我检查以确保它们不是null ...在myList1.Concat(myList2);myList1 之后只包含四个字符串.这是为什么?

c# arrays list concatenation

155
推荐指数
4
解决办法
20万
查看次数

.NET List <T> Concat与AddRange

通用List上的AddRangeConcat函数有什么区别?一个推荐超过另一个?

.net linq extension-methods list

85
推荐指数
3
解决办法
4万
查看次数

标签 统计

list ×2

.net ×1

arrays ×1

c# ×1

concatenation ×1

extension-methods ×1

linq ×1