Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

String.Concat Method (String[])

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


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.