Catch子句用于无休止的重复数字

时间:2012-10-27 00:21:13

标签: c# excel exception sql-server-2008-r2

我正在从C#中加载excel中的值,然后将其转换为一个字符串,然后我想在SQL Server 2008 R2中保存它。如何捕获或重新格式化浮点数,如0.3333333333?

我收到以下错误:指定的强制转换无效。

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

int number = 1;
float number2 = (float)number;
number2.toString("0.00") //2dp - add more zeros to define the number of dp you want