1 回答
TA贡献1921条经验 获得超9个赞
这是一个数据示例:
DataTable table = new DataTable();
table.Columns.Add("C1",typeof(string));
table.Columns.Add("C2",typeof(decimal));
table.Columns.Add("C3",typeof(char));
for(int i = 65; i < 65 + 10; i++)
{
var row = table.NewRow();
row[0] = "string"+i.ToString();
row[1] = i;
row[2] = (char)i;
table.Rows.Add(row);
}
List<Tuple<string, decimal, char>> results = new List< Tuple<string, decimal, char>>();
foreach (DataRow r in table.Rows)
{
var tup = Tuple.Create((string)r[0], (decimal)r[1], (char)r[2]);
results.Add(tup);
}
结果:
Item1 Item2 Item3
string65 65 A
string66 66 B
string67 67 C
string68 68 D
string69 69 E
string70 70 F
string71 71 G
string72 72 H
string73 73 I
string74 74 J
- 1 回答
- 0 关注
- 231 浏览
添加回答
举报