我正在尝试初始化内部包含2个变量的结构的数组。
Private Structure SnakeLocation
Public Row As Integer
Public Column As Integer
End Structure
我尝试了以下方法,但均无济于事。
Private Position As SnakeLocation() = New SnakeLocation() With {.Row = 7, .Column = 8}
Private Position() As SnakeLocation = New SnakeLocation With {.Row = 7, .Column = 8}
我该怎么做?
答案 0 :(得分:2)
你很近。
Dim Position As SnakeLocation() = New SnakeLocation() { new SnakeLocation With {.Row = 7, .Column = 8} }
首先,创建数组并使用SnakeLocation对其进行初始化,然后使用值进行初始化。