如何将数据表转换或复制到字符串数组 [英] How Do Convert Or Copy Datatable To String Array
本文介绍了如何将数据表转换或复制到字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我有一个名为DT1的数据表
该数据表具有:
最大行= 5
列= 1(仅1列)
MyArray是一个字符串数组: string MyArray = new String [5]
我想将这5个单元格复制到MyArray
例子
hi all
i have a Datatable named DT1
this Datatable Have :
Maximum Row = 5
Colum =1 (Only 1 Column)
MyArray Is A String Array : string MyArray= new String[5]
i Want To Do Copy This 5 Cell To MyArray
Example
DataTable Items :
5
4
3
2
1
MyArray Items Must Like Below:
5 4 3 2 1
我该怎么办?
请帮助我
How Do I this ?
Please Help Me
推荐答案
你好
请按照以下步骤操作:
1.数组(C#编程指南)
2.使用迭代器(C#编程指南)
3.使用ADO.Net
4.现在,定义Array [5],迭代读取实体,然后使用实体值设置数组的值.
Hello
Follow the following, step by step:
1. Arrays (C# Programming Guide)
2. Using Iterators (C# Programming Guide)
3. Using ADO.Net
4. Now, Define Array[5], Iterate reading the entity, then set the values of the arrays with entity values.
迭代DataTable中的行,并将每个值放入一个列表或数组.您遇到什么困难?
Iterate through the rows in the DataTable and place each value into a List or array. What part are you having difficulty with?
这篇关于如何将数据表转换或复制到字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文