C# program to separate joined strings in C#


The following is the string array −

string[] str = { "Java", "AngularJS", "Python", "jQuery", "HTML5" };

Firstly, join it −

string.Join(" ", str);

Now to separate the above joined strings, use the Split() method as shown in the following code −

Example

 Live Demo

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);       }    } }

Output

Joined Strings...
Java AngularJS Python jQuery HTML5
Separate Joined Strings...
Java
AngularJS
Python
jQuery
HTML5

Updated on: 22-Jun-2020

35 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements