Join
ExamplesΒΆ
This method returns a new string of items from an array joined by a designated separator between each item. The general syntax for this method is:
string variableName = string.Join(separator, arrayName);
Example
1 2 3 4 5 | string[] fruits = new string[] { "watermelon", "kiwi", "gooseberry"};
string fruitSalad = string.Join("::", fruits);
Console.WriteLine(fruitSalad);
|
Output
watermelon::kiwi::gooseberry
The separator is up to you. Just remember the final outcome is turning your array into a string.