[VB.NET]構造体(Structure)を使うサンプル
書式
Structure 構造体名
処理コード
End Structure
サンプルコード
'構造体の定義 Structure User Public age As Integer Public userName As String '配列 Public cftArr() As String End Structure Module ModuleTest Sub Main() Dim td As User '構造体の変数に値を設定 td.age = 25 td.userName = "testuser007" td.cftArr = {"AA01", "BB02", "CC03"} '構造体の値を表示 Console.WriteLine(td.age) Console.WriteLine(td.userName) Console.WriteLine(td.cftArr(0)) Console.WriteLine(td.cftArr(1)) Console.WriteLine(td.cftArr(2)) End Sub End Module
実行結果
25
testuser007
AA01
BB02
CC03