Greetings All,

i need to convert a functin from vb.net to C#.net here is the vb.net function, when i convert the function using converters i am getting few problems. my main problem is ReDim and ReDim Preserve. these function are not available in C#, how can i convert to C# accordingly. can any body pls provide me a solution. thanks in advance

Protected Function GetRowsList(ByRef oReader As SqlDataReader, Optional ByVal nStart As Long = 1, Optional ByVal nRows As Long = -1)

Dim nCols As Integer

Dim rCnt As Long = 0, nbegin As Long = 0, nEnd As Long = 0, nCol As Long = 0

Dim vaResultSet

Dim bAll As Boolean

Dim bExit As Boolean

Try

Do

rCnt = 0

nCols = oReader.FieldCount()

If nStart = 1 And nRows = -1 Then

nbegin = 0

bAll = True

ElseIf nStart > 0 And nRows = -1 Then

nbegin = nStart - 1

bAll = True

ElseIf (nStart > 0 And nRows > 0) Then

nbegin = nStart - 1

nEnd = nbegin + nRows - 1

End If

Dim vaArray As New ArrayList

While (oReader.Read())

If Not bExit Then

If nbegin <= rCnt And (nEnd >= rCnt Or bAll = True) Then

Try

Dim values(nCols - 1) As Object

oReader.GetValues(values)

vaArray.Add(values)

Catch ex As Exception

HandleError(ex, C_CLASS_NAME)

End Try

ElseIf ((bAll = False) And (nEnd < rCnt)) Then

bExit = True

End If

End If

rCnt = rCnt + 1

End While

If Not IsArray(vaResultSet) Then

ReDim vaResultSet(0)

Else

ReDim Preserve vaResultSet(UBound(vaResultSet) + 1)

End If

Dim vaOut(1)

vaOut(0) = vaArray

vaOut(1) = rCnt

vaResultSet(UBound(vaResultSet)) = vaOut

Loop While oReader.NextResult()

Catch ex As Exception

HandleError(ex, C_CLASS_NAME)

End Try

Return vaResultSet

End Function

 

Regards
sai