Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.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# 将ds.Tables[1].Rows[0].ToString()转换为int_C# - Fatal编程技术网

C# 将ds.Tables[1].Rows[0].ToString()转换为int

C# 将ds.Tables[1].Rows[0].ToString()转换为int,c#,C#,我无法将ds.Tables[1].Rows[0].ToString()转换为int ds.Tables[1].Rows[0] = 100; 给出了一个无法转换的错误 string test = Convert.Int32(ds.Tables[0].Rows[0]["YourIntegerColumn"].ToString()) 如果您的列不是整数,那么它将不起作用,因此您可能需要检查该列是否为null,然后使用int.TryParse检查它是否可解析为int。是否缺少该列? ds.表[1]

我无法将
ds.Tables[1].Rows[0].ToString()
转换为int

ds.Tables[1].Rows[0] = 100; 
给出了一个无法转换的错误

string test = Convert.Int32(ds.Tables[0].Rows[0]["YourIntegerColumn"].ToString())

如果您的列不是整数,那么它将不起作用,因此您可能需要检查该列是否为null,然后使用
int.TryParse检查它是否可解析为int。是否缺少该列?

ds.表[1]。行[0][列]=值

ds.Tables[1]。行[0]返回数据行。您需要指明要分配值的列:

ds.Tables[1].Rows[0]["Your column name"] = value;

如果你想得到答案,你需要发布更多的代码。