BumblebeeTuna
Newcomer
- Joined
- Oct 5, 2006
- Messages
- 1
Hello everyone, could someone please show me how to pass a multidimensional array of a varying size to a class that takes an multidimensional of a varying size. Here is some sample code that I have to better explain.
Inside the class I have this code
Now inside the main form I have this code
Inside the editor, it has MyArray underlined and it says
Value of type '2-dimensional array of Short' cannot be converted to '1-dimensional array of 1-dimensional array of Short' because 'Short' is not derived from '1-dimensional array of Short'.
Inside the class I have this code
Visual Basic:
Public Class MapClass
Public Sub New(ByVal Array()() As Short)
MyBase.New()
'Set The Array Passed In As The Map Array
MapArray = Array
End Sub
Public MapArray()() As Short
Public Sub Check()
MessageBox.Show(MapArray(1)(2).ToString)
End Sub
End Class
Now inside the main form I have this code
Visual Basic:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Size Of The Map
Dim MyArray(10, 10) As Short
MyArray(1, 1) = 3
MyArray(1, 2) = 4
MyArray(1, 3) = 5
Dim MapItem As New MapClass(MyArray)
MapItem.Check()
End Sub
Inside the editor, it has MyArray underlined and it says
Value of type '2-dimensional array of Short' cannot be converted to '1-dimensional array of 1-dimensional array of Short' because 'Short' is not derived from '1-dimensional array of Short'.