Howdy people,
.Net Arrays are slightly confusing to me and these two issues came up.
1) I have a 2 dimensional array of integers representing 2D coordinates (X,Y) what would be the best way to sort it by ascending Y value considering I need the corresponding X values of the Y to follow.
Maybe splitting it into two arrays to use the array.sort() function ?
2) Initialization of an empty array causes issues (=Nothing) when used further in the code.
I made a messy workaround but I'm hoping someone could suggest me a better alternative.
.Net Arrays are slightly confusing to me and these two issues came up.
1) I have a 2 dimensional array of integers representing 2D coordinates (X,Y) what would be the best way to sort it by ascending Y value considering I need the corresponding X values of the Y to follow.
Maybe splitting it into two arrays to use the array.sort() function ?
vb.net Code:
Dim arr_Points As Integer(,)
2) Initialization of an empty array causes issues (=Nothing) when used further in the code.
I made a messy workaround but I'm hoping someone could suggest me a better alternative.
vb.net Code:
Dim arr_Points As Point() If arr_Points IsNot Nothing Then Dim TmP As Point() = arr_Points ReDim arr_Points(TmP.Length) TmP.CopyTo(arr_Points, 0) arr_Points(TmP.Length) = New Point(X_Value, Y) Else ReDim arr_Points(0) arr_Points(0) = New Point(X_Value, Y) End If