我如何在 VB.NET 中创建一个无限范围的数组并获得包含的变量数量?
我试过了:
Dim _items(,) As String
_items(0, 0) = "hy"
_items(0, 1) = "hello"
_items(1, 0) = "bye"
_items(1, 1) = "bye2"
MsgBox(_items.GetLength(1)) 'But i cant get the length
非常感谢
我认为你的语法是错误的
Dim n As Integer = 2
Dim str As String(,) = New String(n - 1, n - 1) {}
MsgBox(_items.GetLength(1)) //if n is 3 then this will return 3
Dim n,m As Integer
n=3,m=2
Dim str As String(,) = New String(n - 1, m - 1) {}
MsgBox(_items.GetLength(1)) // return 2
MsgBox(_items.GetLength(1)) // return 3