C# 程序以字符串形式连接单词
声明一个字符串并添加元素 −
string[] str = { "One", "Two", "Three", "Four", "Five" };
使用 Join() 方法连接单词 −
string res = string.Join(" ", str);
让我们来看看完整的代码 −
示例
using System; public class Demo { public static void Main() { string[] str = { "One", "Two", "Three", "Four", "Five" }; // join words string res = string.Join(" ", str); Console.WriteLine(res); } }
输出
One Two Three Four Five
广告