Question:Which of the following will correctly remove duplicates from a List<T>?
A Int32 index = 0; while (index < list.Count + 1) { if (list[index] == list[index + 1]) list.RemoveAt(index); else index--; }
B List<T> withDupes = LoadSomeData(); List<T> noDupes = new List<T>(new HashSet<T>(withDupes)); withDupes.AddRange(noDupes);
C List<T> withDupes = LoadSomeData(); List<T> noDupes = withDupes.Distinct().ToList();
D List<T> withDupes = LoadSomeData(); var hs = new HashSet<T>(withDupes); withDupes.All( x => hs.Add(x) );
+ AnswerC
+ Report