//小数点后一位 四舍五入 有
Console.WriteLine("原数据 :12345.46");
Console.WriteLine(string.Format("{0:N1}", 12345.46));
//小数点后两位 四舍五入 有
Console.WriteLine("原数据 :123.467");
Console.WriteLine(string.Format("{0:N2}", 123.467));
//百分比 四舍五入 有
Console.WriteLine("原数据 :12.46/100.0");
Console.WriteLine(string.Format("{0:P1}", 12.46/100.0));
//百分比 四舍五入 有
Console.WriteLine("原数据 :0.067307");
Console.WriteLine(string.Format("{0:P3}", 21.0/312.0));
//千分位
Console.WriteLine("原数据 :4567890");
Console.WriteLine(string.Format("{0:#,##0}", 4567890));
//也可以这样格式化
Console.WriteLine((21.0/312.0).ToString("#.##"));
Console.WriteLine((21.245 / 100.0).ToString("#.##"));
//两位保留
Console.WriteLine(string.Format("{0:F2}", 22.345));
//金额输出
Console.WriteLine(string.Format("{0:C2}", 22.345));
//金额输出
Console.WriteLine(string.Format("Total:{0:C}", 1234.5678));
//参数输出
Console.WriteLine("dan价:{0},个数:{1},zong价:{2}",10,5,50);
//日期
Console.WriteLine(string.Format("{0:d}", DateTime.Now));
//时分秒
Console.WriteLine(string.Format("{0:T}", DateTime.Now));
Console.WriteLine(string.Format("{0:R2}", 22.345));
- 大小: 28.6 KB
分享到:
相关推荐
使用c#的string.format 的一些常用的参数
C#String.Format数字格式化输出 .txt
C# String.Format格式说明
C#的String.Format 范例,非常实用的方法全收集到此。
C#String.Format数字格式化输出;有比较详细的讲解。希望对大家有用。
C#String.Format数字格式化输出
C#String.Format格式化输出.pdfC#String.Format格式化输出.pdf
C#String.Format格式化输出.rar
js 写的string format函数,功能模仿C#中的string.Format方法,已实现(整数 :D、小数:F、货币数字:C、科学计数:E 等4种)数字格式化。参数可以传递数组,也可以传多个参数。
C# String.Format格式化输出和ToString()的一些常用用法..docxC# String.Format格式化输出和ToString()的一些常用用法..docx
C# String.Format格式化输出和ToString()的一些常用用法.pdfC# String.Format格式化输出和ToString()的一些常用用法.pdf
C# String.Format格式化输出和ToString()的一些常用用法.docxC# String.Format格式化输出和ToString()的一些常用用法.docx
C# 日期函数 string.Format DateTime dt = DateTime.Now; Label1.Text = dt.ToString();//2005-11-5 13:21:25 Label2.Text = dt.ToFileTime().ToString();//127756416859912816 Label3.Text = dt.ToFileTimeUtc()...
主要介绍了C#中string.format用法,以实例形式较为详细的讲述了string.format格式化的各种用法,非常具有实用价值,需要的朋友可以参考下
JS写的String.Format函数,功能仿照C#的String.Format,参数为JS数组或字符串,使用方法请参考demo
JS仿C#的String.Format函数,参数可以传数组,也可以像C#那样传多个参数
。。。
主要介绍了javascript模拟实现C# String.format函数功能,相信大家可以用的到