Console.Write("{0,-4}",m );
这个语句中,m是要输出的变量,那么双引号花括号里的0和-4是什么意思?
这种问题要善于看msdn
https://msdn.microsoft.com/zh-cn/library/system.string.format.aspx
控制对齐方式
默认情况下,字符串是其字段中左对齐,如果指定字段宽度。 若要右对齐字段中的字符串,则前面加加个负号的字段宽度如 {0,-12} 来定义 12 个字符右对齐字段。
下面的示例类似于前一个,只是右对齐标签和数据。
int[] years = { 2013, 2014, 2015 };
int[] population = { 1025632, 1105967, 1148203 };
String s = String.Format("{0,-10} {1,-10}\n\n", "Year", "Population");
for(int index = 0; index < years.Length; index++)
s += String.Format("{0,-10} {1,-10:N0}\n",
years[index], population[index]);
// Result:
// Year Population
//
// 2013 1,025,632
// 2014 1,105,967
// 2015 1,148,203
例子写的很清楚。