String.Concat Method (Object, Object)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Concatenates the string representations of two specified objects.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- arg0
- Type: System.Object
The first object to concatenate.
- arg1
- Type: System.Object
The second object to concatenate.
Return Value
Type: System.StringThe concatenated string representations of the values of arg0 and arg1.
The method concatenates arg0 and arg1 by calling the parameterless ToString method of arg0 and arg1; it does not add any delimiters.
String.Empty is used in place of any null argument.
If either of the arguments is an array reference, the method concatenates a string representing that array, instead of its members (for example, "System.String[]").
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 */