【发布时间】:2015-03-31 19:38:16
【问题描述】:
我想从我的数据库中获取int 值。我有错误FormatException was unhandled Input string was not in a correct format.
我的代码是
string str = doc_cell.Text;
ulong a = Convert.ToUInt64(str);
【问题讨论】:
-
str 的值是多少?例如,
ulong a = Convert.ToUInt64("234");正在工作。ulong a = Convert.ToUInt64("ab");正在按预期抛出 FormatException。您需要验证您的用户输入。 -
试试这里提到的解决方案stackoverflow.com/questions/10715238/…
标签: c#