int a, b;
a = 10;
b = 30;
Console.WriteLine("第一个数是:{0},第二个数是:{1}", a, b);
Console.WriteLine("第一个数是:{0},第二个数是:{1}", b, a);
Console.WriteLine("第一个数是:{1},第二个数是:{0}", a, b);
Console.ReadKey();
请问
Console.WriteLine("第一个数是:{0},第二个数是:{1}", b, a);
Console.WriteLine("第一个数是:{1},第二个数是:{0}", a, b);
两行在控制台打印出来的结果一样,但是有什么本质的区别呢?
现在已不用这么麻烦了, 直接使用格式化字符串:
Console.WriteLine($"第一个数是:{b},第二个数是:{a}")