-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,968
  • 17
  • 99
  • 158

3 Answers3

2
arraylist.distinct();

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

Graviton
  • 81,782
  • 146
  • 424
  • 602
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,620
  • 4
  • 18
  • 32
-1

Remove duplicates from a List<T> in C#

How do I remove repeated elements from ArrayList?

Community
  • 1
  • 1
Priyank Bolia
  • 14,077
  • 14
  • 61
  • 82