String.Join Method (String, String[], Int32, Int32)
Concatenates the specified elements of a string array, using the specified separator between each element.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
static member Join : separator:string * value:string[] * startIndex:int * count:int -> string
Parameters
- separator
- Type: System.String
The string to use as a separator. separator is included in the returned string only if value has more than one element.
- value
- Type: System.String[]
An array that contains the elements to concatenate.
- startIndex
- Type: System.Int32
The first element in value to use.
- count
- Type: System.Int32
The number of elements of value to use.
Return Value
Type: System.StringA 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.
| Exception | Condition |
|---|---|
| ArgumentNullException | value is a null reference (Nothing in Visual Basic). |
| ArgumentOutOfRangeException | startIndex or count is less than 0. -or- startIndex plus count is greater than the number of elements in value. |
| OutOfMemoryException | Out of memory. |
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 a null reference (Nothing in Visual Basic), an empty string (String.Empty) is used instead. If any element in value is a null reference (Nothing in Visual Basic), an empty string is used instead.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.