Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问数据表行_C#_Asp.net_Datatable - Fatal编程技术网

C# 访问数据表行

C# 访问数据表行,c#,asp.net,datatable,C#,Asp.net,Datatable,我有一个DataTable,我使用foreach循环访问它的行 foreach (DataRow row in table.Rows) { userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]); } 但是知道我的数据表只包含一行,我如何访问它而不通过循环 DataRow row = table.Rows[0]; userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy

我有一个
DataTable
,我使用
foreach
循环访问它的行

foreach (DataRow row in table.Rows)
{
   userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]);
} 

但是知道我的
数据表
只包含一行,我如何访问它而不通过
循环

DataRow row = table.Rows[0];
userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]);

您可以对
行使用索引

DataRow row = table.Rows[0];
userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]);
也有一个like The列。也有一个like The列。