首页 > Windows开发 > 详细

C#double转化成字符串 保留小数位数

时间:2018-05-25 00:50:04      阅读:183      评论:0      收藏:0      [点我收藏+]

double temp=3.1415926;

(F)Fixed point:string str1=temp.toString("f1");//保留一位小数 四舍五入 结果:3.1

(F)Fixed point:string str2=temp.toString("f2");//保留两位小数,四舍五入 下面一次类推 结果:3.14

(N)Number:string str2=temp.toString("N");//保留 结果:3.14

(G)General (default):string str2=temp.toString("G");//保留 结果:3.1415926

(P)Percent:string str2=temp.toString("P");//保留 结果:314.16%

(E)Scientific:string str2=temp.toString("E");//保留 结果E:3.141593E+000

(C)Currency:string str2=temp.toString("C");//保留 结果:¥3.14

C#double转化成字符串 保留小数位数

原文:https://www.cnblogs.com/czicy/p/9085923.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!