Concatenates the specified elements of a string array, using the specified separator between each element.
A string that consists of the strings in value delimited by the separator string.
-or-
string.Empty if count is zero, value has no elements, or separator and all the elements of value are string.Empty.
Type Reason ArgumentOutOfRangeException startIndex plus count is greater than the number of elements in value.
For example, if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", Join(separator, value, 1, 2) returns "orange, grape".
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, 1, 2 ) ); } }
The output is
Green :: Blue