String.Concat Method (String[])

July 28, 2014

Concatenates the elements of a specified String array.

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

public static string Concat(
	params string[] values
)

Parameters

values
Type: System.String []
An array of string instances.

Return Value

Type: System.String
The concatenated elements of values.

ExceptionCondition
ArgumentNullException

values is null.

OutOfMemoryException

Out of memory.

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.

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


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";
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft