String.Concat Method (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.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- values
- Type:
System.String
[]
An array of string instances.
| Exception | Condition |
|---|---|
| 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"; } }
Show: