日期:2014-05-18  浏览次数:20791 次

c#数据结构问题
程序是这样的:我从数据库表中拿到记录遍历,这时需要三个数据结构存储name字段值,在遍历过程中做2次比较,我现在用的是ArrayList,代码如下:
C# code

foreach(String name in Collection)
{
if(!list1.Contains(name))
{
if(!list2.Contains(name))
{
list1.Add(name);
list2.Add(name);
}
}
}


被告知换成set或者map效率高,是hashset和hashmap么?求教

------解决方案--------------------
如果它说的不是c++的set和map,应该是
------解决方案--------------------
C#用dictionary吧,查询肯定是哈希表快的
------解决方案--------------------
5楼6楼正解。