如果我有:
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
包含四个字符串,我按下加号按钮以确保它们不都是空值。
After myList2 = getMeAnotherList();
,myList2
包含六个字符串,我检查以确保它们不为空......在myList1.Concat(myList2);
myList1 仅包含四个字符串之后。这是为什么?