C
creator_bob
How do I create an array of datarows from a sorted list?
I put a bunch of datarows into a sorted list to sort them. Then I got
an array of the sorted elements. However, I cannot typecast them. I
get an invalid cast error. I notice that in the debugger, that arrays
of datarows are listed as {Length=xx}, but my arrays are listed as
{system.array} and refuse to typecast.
Public Class mySortedList
Inherits SortedList
Public ReadOnly Property array() As Object
Get
Dim Result() As Object, X As Integer
ReDim Result(Me.Count - 1)
For X = 0 To Me.Count - 1
Result(X) = Me.GetByIndex(X)
Next
Return Result
End Get
End Property
End Class
Dim O As Object, TestRows() As DataRow
O = EndRingsList.array ' OK to here
TestRows = DirectCast(O, PressData.End_RingsRow()) ' Fails here
O is listed in the debugger as {system.array} instead of {Length=xx}
I put a bunch of datarows into a sorted list to sort them. Then I got
an array of the sorted elements. However, I cannot typecast them. I
get an invalid cast error. I notice that in the debugger, that arrays
of datarows are listed as {Length=xx}, but my arrays are listed as
{system.array} and refuse to typecast.
Public Class mySortedList
Inherits SortedList
Public ReadOnly Property array() As Object
Get
Dim Result() As Object, X As Integer
ReDim Result(Me.Count - 1)
For X = 0 To Me.Count - 1
Result(X) = Me.GetByIndex(X)
Next
Return Result
End Get
End Property
End Class
Dim O As Object, TestRows() As DataRow
O = EndRingsList.array ' OK to here
TestRows = DirectCast(O, PressData.End_RingsRow()) ' Fails here
O is listed in the debugger as {system.array} instead of {Length=xx}