相关疑难解决方法(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万
查看次数

如何编写简单的Html.DropDownListFor()?

在ASP.NET MVC 2中,我想写一个非常简单的下拉列表,它给出了静态选项.例如,我想提供"红色","蓝色"和"绿色"之间的选择.

c# asp.net html.dropdownlistfor asp.net-mvc-2

128
推荐指数
6
解决办法
32万
查看次数