int a = 12345678;
//格式為sring輸出
label1.text = string.format("asdfadsfadsfasdf",a);
label2.text = "asdfadsf"+a.tostring()+"adsfasdf";
label1.text = string.format("asdfadsfadsfasdf",a);//asdfadsf¥1,234.00adsfasdf
label2.text = "asdfadsf"+a.tostring("c")+"adsfasdf";//asdfadsf¥1,234.00adsfasdf
double b = 1234.12543;
int a = 12345678;
//格式為特殊的string樣式輸出
label1.text = string.format("asdfadsfadsfasdf",b);//asdfadsf¥1,234.13adsfasdf
label2.text = "asdfadsf"+b.tostring("c")+"adsfasdf";//asdfadsf¥1,234.13adsfasdf
label1.text = string.format("",b);//¥1,234.125
label2.text = b.tostring("c3");//¥1,234.125
label1.text = string.format("",a);//十進位制--12345678
label2.text = b.tostring("d");//十進位制--相同的型別,轉換報錯
label1.text = string.format("",a);//指數--1.234568e+007
label2.text = b.tostring("e");//指數--1.234125e+003
label1.text = string.format("",a);//定點數--12345678.00
label2.text = b.tostring("f");//定點數--1234.13
label1.text = string.format("",a);//數值--12,345,678.00
label2.text = b.tostring("n");//數值--1,234.13
label1.text = string.format("",a);//十六進製制--bc614e
label2.text = b.tostring("x");//16--帶有小數不能轉換,出錯
label1.text = string.format("",a);//通用為最緊湊--12345678
label2.text = b.tostring("g");//通用為最緊湊--1234.12543
label1.text = string.format("",a);//轉來轉去不損失精度--整數不允許用,報錯
label2.text = b.tostring("r");//轉來轉去不損失精度--1234.12543
double b = 4321.12543;
int a = 1234;
自定義模式輸出:
//"0"描述:佔位符,如果可能,填充位
label1.text = string.format("",a);// 001234
label2.text = string.format("",b);// 004321
//"#"描述:佔位符,如果可能,填充位
label1.text = string.format("",a);// 1234
label2.text = string.format("",b);// 4321
label1.text = string.format("",a);// 01234
label2.text = string.format("",b);// 004321
//"."描述:小數點
label1.text = string.format("",a);
label2.text = string.format("",b);
double b = 87654321.12543;
int a = 12345678;
//","描述:數字分組,也用於增倍器
label1.text = string.format("",a);// 12,345,678
label2.text = string.format("",b);// 87,654,32
label1.text = string.format("",a);// 12346
label2.text = string.format("",b);// 87654
label1.text = string.format("",a);// 12
label2.text = string.format("",b);// 88
label1.text = string.format("",a);// 0
label2.text = string.format("",b);// 0
//"%"描述:格式為百分數
label1.text = string.format("",a);// 1234567800%
label2.text = string.format("",b);// 8765432113%
label1.text = string.format("",a);// 1234567800.00%
label2.text = string.format("",b);// 8765432112.54%
//"abc"描述:顯示單引號內的文字
label1.text = string.format("",a);// 文字12345678
label2.text = string.format("",b);// 文字87654321
//"/"描述:後跟1要列印字的字元,也用於轉移符/n等
label1.text = string.format("/"你好!/"");// "你好!"
label2.text = string.format("[url=file:c//books//new");///c/books/new/we.asp
//"@"描述:後跟要列印字的字元,
label1.text = string.format(@"""你好!"""); // "你好!"要列印"則需要輸入兩對才可以
label2.text = string.format(@"/c/books/new/we.asp");///c/books/new/we.asp
C 數字格式化輸出
int a 12345678 格式為sring輸出 label1.text string.format asdfadsfadsfasdf a label2.text asdfadsf a.tostring adsfasdf label1.text string.format asdfadsfadsf...
C 數字格式化輸出
int a 12345678 格式為sring輸出 label1.text string.format asdfadsfadsfasdf a label2.text asdfadsf a.tostring adsfasdf label1.text string.format asdfadsfadsf...
C 數字格式化輸出
int a 12345678 格式為sring輸出 label1.text string.format asdfadsfadsfasdf a label2.text asdfadsf a.tostring adsfasdf label1.text string.format asdfadsfadsf...