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" }; // join words string res = string.Join(" ", str); Console.WriteLine("Joined Strings...
"+res); string[] convert = res.Split(' '); Console.WriteLine("
Separate 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
广告