人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

May 15, 2006

数字,日期的格式化

Filed under: Code snippets

–Custom Numeric Format Strings

    int a =100;
    Console.WriteLine(a.ToString("000000"));
   

    输出"000100"
  
– Standard Numeric Format Strings
    比如输出16进制数 X or x    Hexadecimal

    Console.WriteLine(a.ToString("X"));

    输出"64"

    Console.WriteLine(a.ToString("X6"));

    输出"000064"

– Composite Formatting

    Each format item takes the following form.
             {index[,alignment][:formatString]}

    String.Format("hours = {0:hh}", DateTime.Now); 得到 hours = 07

    String.Format("Date = {0:yy/MM/dd}", DateTime.Now);  得到 Date = 06-05-15

 

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/05/15/p23/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham