Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

String.Concat Method (Object, Object)

Concatenates the String representations of two specified objects.

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

public static string Concat (
	Object arg0,
	Object arg1
)
public static String Concat (
	Object arg0, 
	Object arg1
)
public static function Concat (
	arg0 : Object, 
	arg1 : Object
) : String

Parameters

arg0

The first Object.

arg1

The second Object.

Return Value

The concatenated String representations of the values of arg0 and arg1.

An Empty string 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 stringConcat5 {
    public static void Main() {
    int i = -123;
    Object o = i;
    Object[] objs = new Object[] {-123, -456, -789};

    Console.WriteLine("Concatenate 1, 2, and 3 objects:");
    Console.WriteLine("1) {0}", String.Concat(o));
    Console.WriteLine("2) {0}", String.Concat(o, o));
    Console.WriteLine("3) {0}", String.Concat(o, o, o));

    Console.WriteLine("\nConcatenate 4 objects and a variable length parameter list:");
    Console.WriteLine("4) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3 element object array:");
    Console.WriteLine("5) {0}", String.Concat(objs));
    }
}
/*
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
*/

import System.*;

class StringConcat5
{
    public static void main(String[] args)
    {
        int i = -123;
        Object o = (Int32)i;
        Object objs[] = new Object[] { (Int32)(-123), (Int32)(-456), 
            (Int32)(-789) };

        Console.WriteLine("Concatenate 1, 2, and 3 objects:");
        Console.WriteLine("1) {0}", String.Concat(o));
        Console.WriteLine("2) {0}", String.Concat(o, o));
        Console.WriteLine("3) {0}", String.Concat(o, o, o));

        Console.WriteLine("\nConcatenate 4 objects and a variable length "
            + "parameter list:");
        Object objArr[] = { o, o, o, o, o };
        Console.WriteLine("4) {0}", String.Concat(objArr));

        Console.WriteLine("\nConcatenate a 3 element object array:");
        Console.WriteLine("5) {0}", String.Concat(objs));
    } //main
} //StringConcat5
/*
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
*/

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft