转换浮点值 [英] Convert Float values

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

问题描述



我在cs页面中有一个变量,类型为Float,

,这个变量值很不好99.3333

和i想要99.33所以请给我一些关于如何转换它的想法

谢谢

hi
I have a variable in the cs page with the type Float,
and this variable values are displey 99.3333
and i want to 99.33 so give me some idea about this how to convert it
Thanks

推荐答案

你可以使用
Math.Round(99.3333, 2)

function。


试试这个

Try this
float d = (float)99.3333;
Console.WriteLine(d.ToString("0.##"));





希望这有助于



Hope this helps


decimal b = 1.995555M;

Math.Round(b, 2); //returns 2.00


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

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