I have a DataRow, I need convert it to a string of array!
Everyone help me, please!
Ex:
MyDataRow include many column(Index type of int, Name type of string, Age type of int.... )
=> to array
array[0]: 1
array[1]: Henry
array[2]: 23
....
-
Welcome to Stack Overflow. This is not a good way to ask a question here. Did you try anything so far to solve your problem? Show your effort first so people might show theirs. Please read FAQ, How to Ask and help center as a start.Nahuel Ianni– Nahuel Ianni2014-09-17 10:15:09 +00:00Commented Sep 17, 2014 at 10:15
Add a comment
|
3 Answers
DataRow itself has property ItemArray, you can use it. Try this code
StringBuilder sb=new StringBuilder();
foreach(DataRow dr in dt.Rows)
{
object[] arr = dr.ItemArray;
for (int i = 0; i < arr.Length; i++)
{
sb.Append(Convert.ToString(arr[i]));
sb.Append("|");
}
}
Response.Write(sb.ToString());