using System;namespace myprog
{class test{static void Main(string[] args){string str1 = string.Format("{0}今年{1}歲,身高{2}cm,月收入{3}元;", "小李", 23, 177, 5000);Console.WriteLine(str1);Console.ReadKey();}}
}
string.Format()第一個雙引號中,{n}是占位符,替換為后面對應的第n個數據,第一個雙引號中的其他內容直接輸出;運行如下;
比使用加號拼接字符串方便一些;在?Console.WriteLine 中也可以使用;?