public static <TSource> ArrayList<TSource> Distinct( ArrayList<TSource> source, IEqualityComparer<TSource> comparer) { ArrayList<TSource> list = new ArrayList<TSource>(); for (TSource a : source) { boolean found = false; for (TSource b : list) { if (comparer.equals(a, b)) { found = true; break; } } if (!found) { list.add(a); } } return list; }