In our code (originally created in .Net 1.1) there are a few examples of "seen" Hashtablepattern
Hashtable seen = new Hashtable();for (int i = 0; i < nCount; i++)
{if (seen[key] == null)
{ //Do the changesseen.Add(key, key);
}
}
It's better to use type-safe HashSet:HashSet<string> seen = new HashSet<string>();
for (int i = 0; i < nCount; i++)
{ if (!seen.Contains(key)) { //Do the changesseen.Add(key);
}
}
No comments:
Post a Comment