「VB.NET」String型の配列を生成するサンプル

書式
Dim 配列名 As String() = New String(){xxx}
配列名(インデックス)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
'String型の配列を生成する
Dim cft As String() = New String() {"study", "skill", "become"}
'配列の3番目を取得する
Dim res As String = cft(2)
Console.WriteLine("配列の3番目の要素: " & res)
'配列の1番目を取得する
Dim res2 As String = cft(0)
Console.WriteLine("配列の1番目の要素: " & res2)
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() 'String型の配列を生成する Dim cft As String() = New String() {"study", "skill", "become"} '配列の3番目を取得する Dim res As String = cft(2) Console.WriteLine("配列の3番目の要素: " & res) '配列の1番目を取得する Dim res2 As String = cft(0) Console.WriteLine("配列の1番目の要素: " & res2) Console.ReadKey() End Sub End Module
Module Module1

    Public Sub Main()

        'String型の配列を生成する
        Dim cft As String() = New String() {"study", "skill", "become"}

        '配列の3番目を取得する
        Dim res As String = cft(2)
        Console.WriteLine("配列の3番目の要素: " & res)

        '配列の1番目を取得する
        Dim res2 As String = cft(0)
        Console.WriteLine("配列の1番目の要素: " & res2)

        Console.ReadKey()
    End Sub

End Module

実行結果
配列の3番目の要素: become
配列の1番目の要素: study

VB.net

Posted by arkgame