How do I properly initialize a multidimensional array within a structure in VB .NET?
How do I properly initialize a multidimensional array within a structure in VB .NET? I thought I understood how the structure was initialized but I seem to be misunderstanding the scope concept.
I have a structure defined:
Public Structure data
Public x(,) As integer ' multidimensional array.
Sub New(ByVal i as integer) ' Constructor sub
ReDim x(i, i) ' Redim to proper bounds
End Sub
End Structure
Public Shared d() as data
Then I have a private sub.
Private Sub MakeNew()
ReDim data(3)
data(0).x(0, 0) = 1
End Sub
What I'm wanting to happen is have an arrayed structure with a 2D array within. But when I try to access the nested 2D array it gives me a: Object reference not set to an instance of an object. exception.
Can anyone help me figure this out?
I'm still pretty new to VB so I assume I'm just missing something here.
|