C#程序在C#中分隔连接的字符串
以下是字符串数组-
string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };
首先,加入它-
string.Join(" ", str);
现在要分离以上连接的字符串,请使用Split()
以下代码中所示的方法-
示例
using System;public class Demo {
public static void Main() {
string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };
//连接词
string res = string.Join(" ", str);
Console.WriteLine("Joined Strings...\n "+res);
string[] convert = res.Split(' ');
Console.WriteLine("\nSeparate Joined Strings...");
foreach (string val in convert) {
Console.WriteLine(val);
}
}
}
输出结果
Joined Strings...Java AngularJS Python jQuery HTML5
Separate Joined Strings...
Java
AngularJS
Python
jQuery
HTML5
以上是 C#程序在C#中分隔连接的字符串 的全部内容, 来源链接: utcz.com/z/326806.html