当前第2页 返回上一页
(1) int i=12345;
1 2 3 4 | this .textBox1.Text=i.ToString();
this .textBox2.Text=i.ToString( "d8" );
|
(2) int i=123;
1 2 3 4 5 6 7 | double j=123.45;
string s1= string .Format( "the value is {0,7:d}" ,i);
string s2= string .Format( "the value is {0,7:f3}" ,j);
this .textBox1.Text=s1 ;
this .textBox2.Text=s2;
|
(3)double i=12345.6789;
1 2 3 | this .textBox1.Text=i.ToString( "f2" );
this .textBox2.Text=i.ToString( "f6" );
|
(4)double i=12345.6789;
1 2 | this .textBox1.Text=i.ToString( "n" );
this .textBox2.Text=i.ToString(“n4”);
|
(5)double i=0.126;
1 2 3 | string s= string .Format( "the value is {0:p}" ,i);
this .textBox1.Text=i.ToString( "p" );
this .textBox2.Text=s;
|
(6) DateTime dt =new DateTime(2003,5,25);
1 2 3 4 5 | this .textBox1.Text=dt.ToString( "yy.M.d" );
this .textBox2.Text=dt.ToString(“yyyy年M月”);
Convert.ToDateTime( "2005/12/22 22:22:22" ).ToString( "yyyy/MM/dd HH:mm:ss" ) "2005/12/22 22:22:22"
|
(7) int i=123;
1 2 3 4 5 | double j=123.45;
string s= string .Format( "i:{0,-7},j:{1,7}" ,i,j);
this .textBox1.Text=s ;
|
以上就是C#中ToString数据类型格式大全(千分符)总结的详细内容!
返回前面的内容
相关阅读 >>
C# winform webbrowser 设置为编辑模式的示例代码
详细介绍C# string格式的日期时间字符串转为datetime类型的方法
用C#描述数据结构1:统计代码执行时间对象的代码详解
具体介绍使用C#访问access数据库时,提示找不到可安装的isam(图)
C#_调用封装的一个类实现导出excel表格的功能
C#如何导入导出与处理excel文件
C#系列文章事件
C#开发实例-订制屏幕截图工具(五)针对拖拽时闪烁卡顿的优化
C#高级编程(二)-核心C#的详解
C# 日志记录类创建的源码分享
更多相关阅读请进入《C#》频道 >>
清华大学出版社
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。
转载请注明出处:木庄网络博客 » C#中ToString数据类型格式大全(千分符)总结