在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();
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:c#拼接字符串的方法是什么