String.Concat Method (Object[])

July 28, 2014

Concatenates the string representations of the elements in a specified Object array.

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

public static string Concat(
	params Object[] args
)

Parameters

args
Type: System.Object []
An object array that contains the elements to concatenate.

Return Value

Type: System.String
The concatenated string representations of the values of the elements in args.

ExceptionCondition
ArgumentNullException

args is null.

OutOfMemoryException

Out of memory.

The method concatenates each object in argsby calling the parameterless ToString method of that object; it does not add any delimiters.

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

The following code example demonstrates the use of the Concat method with an Object array.


using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Create a group of objects.
      Test1 t1 = new Test1();
      Test2 t2 = new Test2();
      int i = 16;
      string s = "Demonstration";

      // Place the objects in an array.
      object[] o = { t1, i, t2, s };

      // Concatenate the objects together as a string. To do this,
      // the ToString method of each of the objects is called.
      outputBlock.Text += string.Concat(o) + "\n";
   }
}

// Create two empty test classes.
class Test1
{
}

class Test2
{
}
// The example displays the following output:
//      Test116Test2Demonstration


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft