在C#中,拼接字符串的方法有以下几种:
string str1 = "Hello"; string str2 = "World"; string result = str1 + " " + str2;
string str1 = "Hello"; string str2 = "World"; string result = String.Concat(str1, " ", str2);
string[] strs = { "Hello", "World" }; string result = String.Join(" ", strs);
string str1 = "Hello"; string str2 = "World"; string result = String.Format("{0} {1}", str1, str2);
StringBuilder sb = new StringBuilder(); sb.Append("Hello"); sb.Append(" "); sb.Append("World"); string result = sb.ToString();