我如何转换双值? [英] How Can I Convert Double Value ?

查看:66
本文介绍了我如何转换双值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在123.3425231134到123.34之类的双变量中更改大量值存储并将其打印到文本框

I want change a large number value store in double variable like 123.3425231134 to 123.34 and get it print to text box

推荐答案

您可以使用string.Format执行此操作:

You can do this with string.Format:
var mytext = string.Format("{0:0,00}",12.3457890125q23)





这会将数字四舍五入为2dp。 mytext的结果将是12.35。因此最后的数字四舍五入



希望有所帮助^ _ ^

Andy



This will round the number to 2dp. The result in mytext will be "12.35". Hence the last digit rounding

Hope that helps ^_^
Andy


这篇关于我如何转换双值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆