
eliminate duplicates in array?
Cynic,
You will need to write some code to do it. Something like:
Dim a As New ArrayList()
a.AddRange(New Integer() {1, 2, 5, 2, 3, 4, 5})
a.Sort()
Dim i As Integer = 1
While i <= a.Count - 1
If CInt(a(i)) = CInt(a(i - 1)) Then
a.RemoveAt(i)
Else
i += 1
End If
End While
Granted you could generalize this using the IComparable interface...
Hope this helps
Jay
Quote:
> Does anyone know of an easy way to eliminate duplicate numbers in an
array?
> For example:
> (1, 2, 2, 3, 4, 5)
> I want to null out that 2nd number 2 element, re-sort
"array.sort(myArray)"
Quote:
> and be left with:
> (1, 2, 3, 4, 5)
> Any suggestions?