问题描述
|
我想从数据表中读取列值,而无需显式指定数据类型和列名。
例如。
int carId = CarTable.Rows[i].Field<int>(\"CarId\"); //this requires the data type and column name.
string name= CarTable.Rows[i].Field<string>(\"Name\");
我想读到carId而不显式指定数据类型和列名。
如果我希望所有列的返回类型都是字符串类型会更容易吗?
解决方法
假设您正在考虑使用列的位置而不是名称,那么您应该能够:
Object colvalue = CarTable.Rows[i].Items[colpos];