Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

String::Join Method (String^, array<Object^>^)


Concatenates the elements of an object array, using the specified separator between each element.

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

static String^ Join(
	String^ separator,
	... array<Object^>^ values


Type: System::String^

The string to use as a separator. separator is included in the returned string only if values has more than one element.

Type: array<System::Object^>^

An array that contains the elements to concatenate.

Return Value

Type: System::String^

A string that consists of the elements of values delimited by the separator string. If values is an empty array, the method returns String::Empty.

Exception Condition

values is null.

If separator is null or if any element of values other than the first element is null, an empty string (String::Empty) is used instead. See the Notes for Callers section if the first element of values is null.

Join(String^, array<Object^>^) is a convenience method that lets you concatenate each element in an object array without explicitly converting its elements to strings. The string representation of each object in the array is derived by calling that object's ToString method.

Notes to Callers:

If the first element of values is null, the Join(String^, array<Object^>^) method does not concatenate the elements in values but instead returns String::Empty. A number of workarounds for this issue are available. The easiest is to assign a value of String::Empty to the first element of the array, as the following example shows.

No code example is currently available or this language may not be supported.

The following example uses the Sieve of Eratosthenes algorithm to calculate the prime numbers that are less than or equal to 100. It assigns the result to a integer array, which it then passes to the Join(String^, array<Object^>^) method.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
© 2017 Microsoft