Enumerable.Distinct returns distinct elements from a sequence by using the default equality comparer to compare values.
Imports System
Imports System.Linq
Imports System.Collections.Generic
Public Class Example
Public Shared Sub Main()
Dim ages As New List(Of Integer)(New Integer() {21, 46, 46, 55, 17, 21, 55, 55})
Dim distinctAges As IEnumerable(Of Integer) = ages.Distinct()
For Each age As Integer In distinctAges
Console.WriteLine(age)
Next
End Sub
End Class
Related examples in the same category