C#中double类型转化成字符串并指定要保留的小数位数

From , 2 Years ago, written in C#, viewed 210 times.
URL https://pastebin.vip/view/e2f374c3
  1. double temp=3.1415926;
  2.  
  3. (F)Fixed point:string str1=temp.toString("f1");//保留一位小数 四舍五入 结果:3.1
  4.  
  5. (F)Fixed point:string str2=temp.toString("f2");//保留两位小数,四舍五入 下面一次类推 结果:3.14
  6.  
  7. (N)Number:string str2=temp.toString("N");//保留 结果:3.14
  8.  
  9. (G)General (default):string str2=temp.toString("G");//保留 结果:3.1415926
  10.  
  11. (P)Percent:string str2=temp.toString("P");//保留 结果:314.16%
  12.  
  13. (E)Scientific:string str2=temp.toString("E");//保留 结果E:3.141593E+000
  14.  
  15. (C)Currency:string str2=temp.toString("C");//保留 结果:¥3.14
  16. //csharp/6045

Reply to "C#中double类型转化成字符串并指定要保留的小数位数"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website