HashSet(T).Contains Method tells whether a HashSet(Of T) object contains the specified element.
Imports System
Imports System.Collections.Generic
Class Program
Shared Sub Main()
Dim evenNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()
For i As Integer = 0 To 19
evenNumbers.Add(i)
Next i
Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
evenNumbers.RemoveWhere(AddressOf isEven)
Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
If evenNumbers.Contains(0) Then
evenNumbers.Remove(0)
End If
Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
End Sub
Private Shared Function isEven(ByVal i As Integer) As Boolean
Return ((i Mod 2) = 1)
End Function
End Class
Related examples in the same category