如果我有:
在
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?
我在Visual Studio 2008中运行了类似于以下代码的程序,并在每次执行后设置了断点。在 myList1 = getMeAList();
执行之后,myList1
包含了四个字符串,我按下加号按钮以确认它们不全为空。在
myList2 = getMeAnotherList();
之后,myList2
包含六个字符串,我检查它们是否为空... 在 myList1.Concat(myList2);
之后,myList1
仅包含四个字符串。这是为什么呢?
IEnumerable<T>
。 - Jonathan Rupp