合并两个列表,然后对合并列表进行排序

时间:2016-04-17 18:07:15

标签: c#

我必须合并两个列表并对它们进行排序,但不理解我在尝试对新的合并列表进行排序时出现的错误背后的含义。 “无法将类型'void'隐式转换为'System.Collections.Generic.List'”这是我在result.Sort()上得到的错误;

>>> a = sum(a)

2 个答案:

答案 0 :(得分:3)

问题是result.Sort()方法没有返回任何内容。它只对现有的result列表进行排序。 所以代码应该是

result.Sort();

foreach (var i in result) 
{
    Console.WriteLine(i);
}

答案 1 :(得分:1)

排序函数是一个更改函数调用的列表的函数(不返回排序列表,但更改列表)。 因此,在您的示例中,您应该:

#Text {
position: absolute;
background-image: url("http://support.leagueapps.com/customer/portal/attachments/28383");
color: #3399ff;
border-color: Lightblue;
border-style: double;
border-width: 5px;
top: 160px;
left: 150px;
height: 1500px;
width: 900px;
font-size: 13pt;
font-family: Franklin Gothic Medium;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
box-shadow: 10px 10px 10px grey;
border-radius: 20px;
}