This documentation is archived and is not being maintained.
String::Join Method (String, array<String>)
Visual Studio 2010
Concatenates all the elements of a string array, using the specified separator between each element.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- separator
- Type: System::String
The string to use as a separator.
- value
- Type: array<System::String>
An array that contains the elements to concatenate.
Return Value
Type: System::StringA string that consists of the elements in value delimited by the separator string. If value is an empty array, the method returns String::Empty.
| Exception | Condition |
|---|---|
| ArgumentNullException | value is nullptr. |
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 nullptr, an empty string (String::Empty) is used instead. If any element in value is nullptr, an empty string is used instead.
The following example demonstrates the Join method.
using namespace System; String^ MakeLine( int initVal, int multVal, String^ sep ) { array<String^>^sArr = gcnew array<String^>(10); for ( int i = initVal; i < initVal + 10; i++ ) sArr[ i - initVal ] = String::Format( "{0, -3}", i * multVal ); return String::Join( sep, sArr ); } int main() { Console::WriteLine( MakeLine( 0, 5, ", " ) ); Console::WriteLine( MakeLine( 1, 6, " " ) ); Console::WriteLine( MakeLine( 9, 9, ": " ) ); Console::WriteLine( MakeLine( 4, 7, "< " ) ); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, 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.
Show: