System.String.Join Method

Concatenates the members of a constructed IEnumerable`1 collection of type string, using the specified separator between each member.


public static string Join (string separator, IEnumerable<string> values)


The string to use as a separator. separator is included in the returned string only if values has more than one element.
A collection that contains the strings to concatenate.


A string that consists of the members of values delimited by the separator string. If values has no members, the method returns string.Empty.


If separator is null, an empty string (string.Empty) is used instead. If any member of values is null, an empty string is used instead.

string.Join(string, IEnumerable<string>) is a convenience method that lets you concatenate each element in an IEnumerable(Of String) collection without first converting the elements to a string array. It is particularly useful with Language-Integrated Query (LINQ) query expressions. The following example passes a List(Of String) object that contains either the uppercase or lowercase letters of the alphabet to a lambda expression that selects letters that are equal to or greater than a particular letter (which, in the example, is "M"). The IEnumerable(Of String) collection returned by the System.Linq.Enumerable.Where``1(IEnumerable<``0>, Func<``0, bool>) method is passed to the string.Join(string, IEnumerable<string>) method to display the result as a single string.

code reference: System.String.Join#4


Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: