[VB.NET]ClearでHashSetのすべて要素を削除する
書式
HashSet変数名.Clear()
使用例
Module Module1
Sub Main()
'HashSet型変数の定義
Dim hs As New HashSet(Of Integer)
'要素を追加
hs.Add(11)
hs.Add(22)
hs.Add(33)
hs.Add(44)
'要素数を取得
Console.WriteLine(hs.Count)
hs.Clear()
Console.WriteLine("全ての要素を削除")
Console.WriteLine(hs.Count)
Console.ReadKey()
End Sub
End Module
結果
4
全ての要素を削除
0