【发布时间】:2013-06-07 11:54:11
【问题描述】:
我正在尝试获取一个唯一的、按字母顺序排列的行业名称(字符串)列表。这是我的代码:
HashSet<string> industryHash = new HashSet<string>();
List<string> industryList = new List<string>();
List<string> orderedIndustries = new List<string>();
// add a few items to industryHash
industryList = industryHash.ToList<string>();
orderedIndustries = industryList.Sort(); //throws compilation error
最后一行抛出编译错误: "不能将类型 'void' 隐式转换为 'System.Collections.Generic.List"
我做错了什么?
【问题讨论】:
-
当您使用它时,您也可以使用 OrderedSet 顺便说一句。 msdn.microsoft.com/en-us/library/dd412070.aspx
标签: c# list sorting asp.net-3.5 hashset