格式化字符串
對字符串格式化的輸出:
Console.WriteLine("兩個數(shù)相加{0}+{1}={2}",4,6,10);
多重標(biāo)記
Console.WriteLine("Three integers are {1},{0} and {1}",3,5);
但是標(biāo)記不能引用超出替換值列表長度以外位置的值
Console.WriteLine("Two integers are {0} and {2}",3,6); ?//錯誤
對字符串格式化的輸出:
Console.WriteLine("兩個數(shù)相加{0}+{1}={2}",4,6,10);
Console.WriteLine("Three integers are {1},{0} and {1}",3,5);
但是標(biāo)記不能引用超出替換值列表長度以外位置的值
Console.WriteLine("Two integers are {0} and {2}",3,6); ?//錯誤