C# program to separate joined strings in C#

CsharpProgrammingServer Side Programming

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...\n "+res);
      string[] convert = res.Split(' ');
      Console.WriteLine("\nSeparate 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
raja
Published on 04-Sep-2018 10:39:54
Advertisements