remove duplicated value in arraylist

buggiez

Member
Joined
Feb 7, 2006
Messages
18
Location
Singapore
Programming Experience
1-3
supposingly i have an arraylist of userIDs, and there are a few duplicated userIDs in the arraylist (i.e. there are 2 records of userID: "21")

how do i actually remove the record out of the duplicated record, to make only unique userIDs to stay in the arraylist? that is, to have only a single record of each userID (i.e. there will only be 1 record of userid: "21")

thanks in advance
 
Copy the unique to new list:
VB.NET:
'test data
Dim original As New List(Of Integer)
original.AddRange(New Integer() {1, 2, 3, 1, 2, 3})
 
'get unique items
Dim unique As New List(Of Integer)
For Each int As Integer In original
    If Not unique.Contains(int) Then unique.Add(int)
Next
 
Back
Top