How to remove duplicate sets of items from a list in VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()

        Dim list As New List(Of String)(New String() {"c#", "vb.net", "c", "c", "php", "php"})

        list = RemoveDuplicatesSet(list)

        Dim s As String = String.Join(" ", list.ToArray())

        Console.WriteLine(s)

    End Sub

    Function RemoveDuplicatesSet(ByVal items As List(Of String)) As List(Of String)
        Dim result As New List(Of String)

        For i = 0 To items.Count - 1
            If (Not result.Contains(items(i))) Then
                result.Add(items(i))
            End If
        Next

        Return result
    End Function


End Module

' run:
' 
' c# vb.net c php java

 



answered Aug 27, 2018 by avibootz
...