以下是字符串数组-
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