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)

Creates the String representation of a specified object.

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

public static string Concat (
	Object arg0
)
public static String Concat (
	Object arg0
)
public static function Concat (
	arg0 : Object
) : String
Not applicable.

Parameters

arg0

An Object or a null reference (Nothing in Visual Basic).

Return Value

The String representation of the value of arg0.

An Empty string is used in place of any null argument.

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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

Show:
© 2014 Microsoft