remove dups from ArrayList

  • Thread starter Thread starter DaveF
  • Start date Start date
Is these an easy way to remove duplicate values in an ArrayList?

This method will do the magic for you:
public static ArrayList RemoveDuplicates(ArrayList list) {
ArrayList ret=new ArrayList();
foreach (object obj in list) {
if (!ret.Contains(obj)) ret.Add(obj);
}
return ret;
}

Anders Norås
blog: http://dotnetjunkies.com/weblog/anoras
 
Back
Top