如何将datarow转换为数组串?

时间:2014-09-17 10:05:42

标签: c# arrays datarow

我有一个DataRow,我需要将它转换为一个数组字符串! 请各位帮助我! 例如: MyDataRow包含许多列(int的索引类型,字符串的Name类型,int的Age类型....) => to array array[0]: 1 array[1]: Henry array[2]: 23 ....

3 个答案:

答案 0 :(得分:2)

DataRow本身具有属性ItemArray,您可以使用它。 试试这段代码

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());

答案 1 :(得分:0)

只需转换如下。

A Parser-blocking, cross-origin script, https://linkhelp.clients.google.com/tbproxy/lh/wm?sourceid=wm&url=http%3A%2F%2Flocalhost%3A8080%2F&hl=en&site=localhost%3A8080&error=http404&js=true, is invoked via document.write. 

This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.

hb @ fixurl.js:135

答案 2 :(得分:0)

轻松使用Linq:

sudo npm i -g @angular/cli@latest