初始化数组的位置发生错误。
我如何使用该阵列?
它必须是一个二维数组的字符......
谢谢....
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
Public Structure ST_TEST
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=360)>
Public 2D_CHAR_ARR()() As Char '//Array In Struct can not be fixed row&col
End Structure
''''''''''''''''''''''''''''''''''''''''
Dim stTest As ST_TEST
ReDim stTest.2D_CHAR_ARR(60)(60) ' //throws System.NullReferenceException
答案 0 :(得分:1)
出现空引用,因为您定义的数组不是方形数组而是数组数组。要ReDim
,你需要写一些类似
ReDim MyArray(60)
For i As Integer = 0 To 60
ReDim MyArray(i)(60)
Next i
如果你想要一个正方形数组,你应该声明它
Public MyArray(60, 60)
答案 1 :(得分:0)
多维数组
Dim matrix = New Integer(4, 4) {{1, 2}, {3, 4}, {5, 6}, {7, 8}}
锯齿状阵列
Dim sales()() As Double = New Double(11)() {}