文档详情

2简单的C程序设计.ppt

发布:2017-05-19约4.94千字共19页下载文档
文本预览下载声明
下面的语句会产生同样的输出: public class TestConsoleApp { ???? public static void Main(string[] args) ???? { ???????? Console.WriteLine(123); ???????? Console.WriteLine({0}, 123); ???????? Console.WriteLine({0:D3}, 123); ???? } } 输出是: 123 123 123 也可以通过String.Format得到同样的输出。 string s = string.Format(123); string t = string.Format({0}, 123); string u = string.Format({0:D3}, 123); Console.WriteLine(s); Console.WriteLine(t); Console.WriteLine(u); 格式化标识符 Standard Numeric Format Specifiers (C) Currency: . . . . . . . . ($123.00) (D) Decimal:. . . . . . . . . -123 (E) Scientific: . . . . . . . -1.234500E+002 (F) Fixed point:. . . . . . . -123.45 (G) General:. . . . . . . . . -123 ??? (default):. . . . . . . . -123 (default = G) (N) Number: . . . . . . . . . -123.00 (P) Percent:. . . . . . . . . -12,345.00 % (R) Round-trip: . . . . . . . -123.45 (X) Hexadecimal:. . . . . . . FFFFFF85 Standard DateTime Format Specifiers (d) Short date: . . . . . . . 6/26/2004 (D) Long date:. . . . . . . . Saturday, June 26, 2004 (t) Short time: . . . . . . . 8:11 PM (T) Long time:. . . . . . . . 8:11:04 PM (f) Full date/short time: . . Saturday, June 26, 2004 8:11 PM (F) Full date/long time:. . . Saturday, June 26, 2004 8:11:04 PM (g) General date/short time:. 6/26/2004 8:11 PM (G) General date/long time: . 6/26/2004 8:11:04 PM ??? (default):. . . . . . . . 6/26/2004 8:11:04 PM (default = G) (M) Month:. . . . . . . . . . June 26 (R) RFC1123:. . . . . . . . . Sat, 26 Jun 2004 20:11:04 GMT (s) Sortable: . . . . . . . . 2004-06-26T20:11:04 (u) Universal sortable: . . . 2004-06-26 20:11:04Z (invariant) (U) Universal full date/time: Sunday, June 27, 2004 3:11:04 AM (Y) Year: . . . . . . . . . . June, 2004 Standard Enumeration Format Specifiers (G) General:. . . . . . . . . Green ??? (default):. . . . . . . . Green (default = G) (F) Flags:. . . . . . . . . . Green (flags or integer) (D) Decimal number: . . . . . 3 (X) Hexadecimal:. . . . . . . public class FormatSpecA
显示全部
相似文档