Export (0) Print
Expand All

String.Concat Method (Object)

Updated: October 2010

Creates the String representation of a specified object.

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

public static string Concat(
	Object arg0
)

Parameters

arg0
Type: System.Object
The object to represent, or null.

Return Value

Type: System.String
The string representation of the value of arg0, or String.Empty if arg0 is null.

The Concat method represents arg0 as a string by calling its parameterless ToString method. An Empty string is used in place of any null argument.

The following code example demonstrates the Concat method.


using System;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      int i = -123;
      Object o = i;
      Object[] objs = new Object[] { -123, -456, -789 };

      outputBlock.Text += String.Format("Concatenate 1, 2, and 3 objects:") + "\n";
      outputBlock.Text += String.Format("1) {0}", String.Concat(o)) + "\n";
      outputBlock.Text += String.Format("2) {0}", String.Concat(o, o)) + "\n";
      outputBlock.Text += String.Format("3) {0}", String.Concat(o, o, o)) + "\n";

      outputBlock.Text += "\nConcatenate 4 objects and a variable length parameter list:" + "\n";
      outputBlock.Text += String.Format("4) {0}", String.Concat(o, o, o, o, o)) + "\n";

      outputBlock.Text += "\nConcatenate a 3 element object array:" + "\n";
      outputBlock.Text += String.Format("5) {0}", String.Concat(objs)) + "\n";
   }
}
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/


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.

Date

History

Reason

October 2010

Expanded the Remarks section.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft