Splitting and Joining a string

Akiii
Posted by Akiii under C# category on | Points: 40 | Views : 2007
Here I am using a console application. First we will split the string and then we will join it. Splitting a string need some argument or something to split and the same is with joining also.

string myString = "Dotnet Funda";
string[] myArray = myString.Split(' ');

for (int i = 0; i < myArray.Length; i++)
{
Console.WriteLine(myArray[i]);
}

string jString = string.Join("----", myArray);
Console.WriteLine(jString);

Console.ReadLine();


In the above, we have taken a string variable with value as "Dotnet Funda". We have splitted the string using 'space', stored in an array and used a for loop to view the output.
Similarly, we have joined a string using '----'.


I hope the above is useful !


Thanks and Regards
Akiii

Comments or Responses

Login to post response