This question is locked. New answers and comments are not allowed.
Hi,
if I convert to c# this
Function GetData(ByVal a_dtData As System.Data.DataTable) As Object
Dim obj As Object = New Object((a_dtData.Rows.Count + 1) - 1, a_dtData.Columns.Count - 1)
Try
For j As Integer = 0 To a_dtData.Columns.Count - 1
obj(0, j) = a_dtData.Columns(j).Caption
Next
Dim dt As New DateTime()
Dim sTmpStr As String = String.Empty
For i As Integer = 1 To a_dtData.Rows.Count
For j As Integer = 0 To a_dtData.Columns.Count - 1
If a_dtData.Columns(j).DataType Is dt.[GetType]() Then
If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then
DateTime.TryParse(a_dtData.Rows(i - 1)(j).ToString(), dt)
obj(i, j) = dt.ToString("MM/dd/yy hh:mm tt")
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
ElseIf a_dtData.Columns(j).DataType Is sTmpStr.[GetType]() Then
If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then
sTmpStr = a_dtData.Rows(i - 1)(j).ToString().Replace(vbCr, "")
obj(i, j) = sTmpStr
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
Next
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return obj
End Function
the array usage is converted as () instead of [ ].
regards
if I convert to c# this
Function GetData(ByVal a_dtData As System.Data.DataTable) As Object
Dim obj As Object = New Object((a_dtData.Rows.Count + 1) - 1, a_dtData.Columns.Count - 1)
Try
For j As Integer = 0 To a_dtData.Columns.Count - 1
obj(0, j) = a_dtData.Columns(j).Caption
Next
Dim dt As New DateTime()
Dim sTmpStr As String = String.Empty
For i As Integer = 1 To a_dtData.Rows.Count
For j As Integer = 0 To a_dtData.Columns.Count - 1
If a_dtData.Columns(j).DataType Is dt.[GetType]() Then
If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then
DateTime.TryParse(a_dtData.Rows(i - 1)(j).ToString(), dt)
obj(i, j) = dt.ToString("MM/dd/yy hh:mm tt")
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
ElseIf a_dtData.Columns(j).DataType Is sTmpStr.[GetType]() Then
If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then
sTmpStr = a_dtData.Rows(i - 1)(j).ToString().Replace(vbCr, "")
obj(i, j) = sTmpStr
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
Else
obj(i, j) = a_dtData.Rows(i - 1)(j)
End If
Next
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return obj
End Function
the array usage is converted as () instead of [ ].
regards