【发布时间】:2015-03-17 12:58:11
【问题描述】:
好的,我想出了什么,但我想知道这是最有效的方法。我需要针对 ram 内存问题执行此操作。
HashSet<string> hsLinks = new HashSet<string>();
List<string> lstSortList = new List<string>();
// fill hashset with millions of records
while (true)
{
string srLastitem = "";
foreach (var item in hsLinks)
{
srLastitem = item;
break;
}
lstSortList.Add(srLastitem);
hsLinks.Remove(srLastitem);
if (hsLinks.Count == 0)
break;
}
c# .net 4.5.2 wpf 应用程序
【问题讨论】:
-
首先有什么阻止您使用 hsLinks.first() 而不是那个 foreach 循环吗?
-
你想做什么?