Tags

, , ,

Hey,

This is in continuation to my previous post where I discussed about splitting the string on Delimiter basis. Here I would give an example of the opposite ; Joining various strings in an array to a single string using a delimiter.

It is possible by using Join method.

Eg:

String[] Words = new String[4];

Words[0]="My";
Words[1]="Name";
Words[2]="is";
Words[3]="Ashwani";
String Sentence = String.Join(" ",Words);

Output:

Sentence = My name is Ashwani

In my case I used it with a comma delimiter as:

String Hobby = String.Join(",", Hobbies);

This joined all the hobbies of a person in different index of an Array(String) Hobbies to a single String Hobby using Comma separated;

 
Thanks !!!
🙂

 

Advertisements