String.Concat Method (array<String>[]()[])

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Concatenates the elements of a specified String array.

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

Syntax

Public Shared Function Concat ( _
    ParamArray values As String() _
) As String
public static string Concat(
    params string[] values
)

Parameters

Return Value

Type: System..::.String
The concatenated elements of values.

Exceptions

Exception Condition
ArgumentNullException

values is nullNothingnullptra null reference (Nothing in Visual Basic).

OutOfMemoryException

Out of memory.

Remarks

The method concatenates each object in values; it does not add any delimiters.

An Empty string is used in place of any null object in the array.

Examples

The following code example demonstrates the use of the Concat method with a String array.


Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim s As String() = {"hello ", "and ", "welcome ", "to ", "this ", "demo! "}

      ' make an array of strings. Note that we have included spaces

      ' put all the strings together
      outputBlock.Text &= String.Concat(s) & vbCrLf

      ' sort the strings, and put them together
      Array.Sort(s)
      outputBlock.Text &= String.Concat(s) & vbCrLf
   End Sub 'Main
End Class 'ConcatTest
using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // make an array of strings. Note that we have included spaces
      string[] s = { "hello ", "and ", "welcome ", "to ", "this ", "demo! " };

      // put all the strings together
      outputBlock.Text += string.Concat(s) + "\n";

      // sort the strings, and put them together
      Array.Sort(s);
      outputBlock.Text += string.Concat(s) + "\n";
   }
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

String Class

Concat Overload

System Namespace

Join