Partager via


String.Concat Method (array<String[])

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Concatenates the elements of a specified String array.

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

Syntax

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

Parameters

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

Return Value

Type: System.String
The concatenated elements of values.

Exceptions

Exception Condition
ArgumentNullException

values is nulla 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

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

Platforms

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