String::Join Method (String, IEnumerable<String>)
Concatenates the members of a constructed IEnumerable<T> collection of type String, using the specified separator between each member.
Assembly: mscorlib (in mscorlib.dll)
[ComVisibleAttribute(false)] public: static String^ Join( String^ separator, IEnumerable<String^>^ values )
Parameters
- separator
- Type: System::String
The string to use as a separator.
- values
- Type: System.Collections.Generic::IEnumerable<String>
A collection that contains the strings to concatenate.
Return Value
Type: System::StringA string that consists of the members of values delimited by the separator string. If values has no members, the method returns String::Empty.
| Exception | Condition |
|---|---|
| ArgumentNullException | values is nullptr. |
If separator is nullptr, an empty string (String::Empty) is used instead. If any member of values is nullptr, an empty string is used instead.
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 Enumerable::Where method is passed to the Join(String, IEnumerable<String>) method to display the result as a single string.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.