Console.Write()方法将指定的值输出到控制台窗口
Console.WriteLine()方法类似,但是在输出结果最后添加一个换行符
example_1:
int i=10;
int j=20;
Console.WriteLine("{0} plus {1} equal {2}",i,j,i+j);
output:
10 plus 20 equal 30
example_2
int i = 940;
int j = 73;
Console.WriteLine("{0,4}\n+{1,3}\n---- \n{2,4}", i, j, i + j);
output:
940
+ 73
----
1013
参数说明:
{n,w},其中n是参数索引,w是宽度值(正号表示右对齐,负号表示左对齐)。