-1

I have a array list which have a list of a type, but all values are duplicated.

Specifically, my blog url is in my array list twice. How can I remove the duplicates?

durron597
  • 31,426
  • 16
  • 97
  • 154

3 Answers3

2
arraylist.distinct();

Make sure you have using System.linq at the top of your cs file.

Graviton
  • 79,554
  • 141
  • 413
  • 589
0

The earlier answer is correct but just to add to it, you need to specify the type when you create the list. Arraylist does not have a distinct method by itself. Here is how you would do it,

List<string> foo = new List<string>();
foo.Add("sample");
foo.Add("sample");
...
IEnumerable bar = foo.Distinct();
theraneman
  • 1,572
  • 4
  • 17
  • 32
-1

Remove duplicates from a List<T> in C#

How do I remove repeated elements from ArrayList?

Community
  • 1
  • 1
Priyank Bolia
  • 13,629
  • 13
  • 59
  • 82