且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

指定的转换是无效的。如何解决这个

更新时间:2022-10-31 18:34:46

使用 Convert.ToDouble(值),而不是(双)值。它需要一个对象,并支持所有你要的类型! :)

Use Convert.ToDouble(value) rather than (double)value. It takes an object and supports all of the types you asked for! :)

另外,你的方法总是返回字符串在上面的代码;我建议具有方法提示并给它一个更明显的名称(公共字符串FormatLargeNumber(对象的值)

Also, your method is always returning a string in the code above; I'd recommend having the method indicate so, and give it a more obvious name (public string FormatLargeNumber(object value))