下面一个例子可以更直观的说明作用
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 1;
int b = 2;
int c = 3;
Console.WriteLine("{0}{1}{2}",a,b,c);
Console.WriteLine("{1}{2}", a, b, c);
//Console.WriteLine("{0}{1}{2}", b, c); //错误占了三个位置却只有两个值输出
Console.WriteLine("{0}{1}{2}{0}{1}{2}{0}{1}{2}", a, b, c);
Console.WriteLine("{0}{1}{2}", b, a, c);
Console.WriteLine("{0},{1},{2}", a, b, c);
Console.WriteLine("{0} {1} {2}", a, b, c);
Console.WriteLine("{0}-{1}-{2}", a, b, c);
Console.ReadLine();
}
}
}
运行结果如下: