C#程序将单词连接成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" };
//连接词
string res = string.Join(" ", str);
Console.WriteLine(res);
}
}输出结果
One Two Three Four Five
热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语