欢迎光临散文网 会员登陆 & 注册

c#特殊的输出方式

2020-05-25 17:28 作者:unity_某某师_高锦锦  | 我要投稿

 // Format a negative integer or floating-point number in various ways.

            Console.WriteLine("Standard Numeric Format Specifiers");

            Console.WriteLine(

                "(C) 货币: . . . . . . . . {0:C}\n" +

                "(D) 十进制小数:. . . . . . . . . {0:D}\n" +

                "(E) 科学计数写法: . . . . . . . {1:E}\n" +

                "(F) 固定点:. . . . . . . {1:F}\n" +

                "(G) 普通的:. . . . . . . . . {0:G}\n" +

                "    (默认的):. . . . . . . . {0} (default = 'G')\n" +

                "(N) 数字显示: . . . . . . . . . {0:N}\n" +

                "(P) 百分比:. . . . . . . . . {1:P}\n" +

                "(R) 双程的: . . . . . . . {1:R}\n" +

                "(X) 16进制的:. . . . . . . {0:X}\n",

                -123, -123.45f);


            // Format the current date in various ways. 时间的显式的方式

            Console.WriteLine("Standard DateTime Format Specifiers");

            Console.WriteLine(

                "(d) Short date: . . . . . . . {0:d}\n" +

                "(D) Long date:. . . . . . . . {0:D}\n" +

                "(t) Short time: . . . . . . . {0:t}\n" +

                "(T) Long time:. . . . . . . . {0:T}\n" +

                "(f) Full date/short time: . . {0:f}\n" +

                "(F) Full date/long time:. . . {0:F}\n" +

                "(g) General date/short time:. {0:g}\n" +

                "(G) General date/long time: . {0:G}\n" +

                "    (default):. . . . . . . . {0} (default = 'G')\n" +

                "(M) Month:. . . . . . . . . . {0:M}\n" +

                "(R) RFC1123:. . . . . . . . . {0:R}\n" +

                "(s) Sortable: . . . . . . . . {0:s}\n" +

                "(u) Universal sortable: . . . {0:u} (invariant)\n" +

                "(U) Universal full date/time: {0:U}\n" +

                "(Y) Year: . . . . . . . . . . {0:Y}\n",

                thisDate);


            // Format a Color enumeration value in various ways.

            Console.WriteLine("Standard Enumeration Format Specifiers");

            Console.WriteLine(

                "(G) General:. . . . . . . . . {0:G}\n" +

                "    (default):. . . . . . . . {0} (default = 'G')\n" +

                "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" +

                "(D) Decimal number: . . . . . {0:D}\n" +

                "(X) Hexadecimal:. . . . . . . {0:X}\n",

                Color.Green);


c#特殊的输出方式的评论 (共 条)

分享到微博请遵守国家法律