如果我有:
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只包含四个字符串。为什么呢?