Concatenates all the elements of a string array, using the specified separator between each element.
A string that consists of the elements in value delimited by the separator string. If value is an empty array, the method returns string.Empty.
Type Reason ArgumentNullException value is a null reference.
For example, if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", Join(separator, value) returns "apple, orange, grape, pear".
If separator is null, an empty string (string.Empty) is used instead. If any element in value is null, an empty string is used instead.
The following example demonstrates the string.Join(string, String[]) method.
C# Example
using System; public class StringJoin { public static void Main() { String[] strAry = { "Red" , "Green" , "Blue" }; Console.WriteLine( String.Join( " :: ", strAry ) ); } }
The output is
Red :: Green :: Blue