「VB.NET」HashSet要素数を取得する

2021年9月14日

書式
Dim 変数名 As New HashSet(Of データの型)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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)
Console.ReadKey()
End Sub
End Module
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) Console.ReadKey() End Sub End Module
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)
        Console.ReadKey()

    End Sub

End Module

結果
4

VB.net

Posted by arkgame