如何解决'System.Data.DataRow'以输入'System.IConvertible'。“在c#? [英] How to solve 'System.Data.DataRow' to type 'System.IConvertible'." in c#?
本文介绍了如何解决'System.Data.DataRow'以输入'System.IConvertible'。“在c#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (转换 .ToInt32(dsavailablity.Tables [< span class =code-digit> 0 ]。Rows.Count)> 转换 .ToInt32(dsavailablity.Tables [ 0 ]。行[i]))
当我检查这个条件时我收到此错误< span class =code-string> 无法将System.Data.DataRow类型的对象强制转换为System.IConvertible。请为我提供 的解决方案。
解决方案
你无法转换一整行到一个int!它不起作用,因为一行包含零个或多个值 - 并且它不能将多个值转换为int。
尝试:
Convert.ToInt32(dsavailablity.Tables [ 0 ]。行[i] .Cells [ 0 ])
if (Convert.ToInt32(dsavailablity.Tables[0].Rows.Count) > Convert.ToInt32(dsavailablity.Tables[0].Rows[i]))
While i checking this condition i am getting this error "Unable to cast object of type 'System.Data.DataRow' to type 'System.IConvertible'." pls provide me solution for that.
解决方案
You can't convert a whole row to an int! It doesn't work because a row contains zero or more values - and it can't convert more than one value to an int.
Try:
Convert.ToInt32(dsavailablity.Tables[0].Rows[i].Cells[0])
这篇关于如何解决'System.Data.DataRow'以输入'System.IConvertible'。“在c#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文