数字,日期的格式化
–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
