C#字符串拼接的三种方式
static void Main(string[] args) { string name = "asher"; //方法1 string str1 = "hello " + name; //方法2 string str2 = string.Format("hello {0}", name); //方法3 string str3 = $"hello {name}"; Console.WriteLine(str1); Console.WriteLine(str2); Console.WriteLine(str3); Console.ReadKey(); }
运行结果: