C#格式化输出内容
nt k = 16; Console.WriteLine(" '{0,-8}'",k); // produces: '16 ' Console.WriteLine(" '{0,8}'",k); // produces: ' 16' Console.WriteLine(" '{0,8}'","Test"); // produces: ' Test' Console.WriteLine(" '{0,-8}'","Test");// produces: 'Test ' Console.WriteLine(" '{0:X}'",k); //(in HEX) produces: '10' Console.WriteLine(" '{0:X10}'",k); //(in HEX) produces:'0000000010' Console.WriteLine( 1234567.ToString("#,##0")); // writes with commas: 1,234,567