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[])

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
)
public static String Concat (
	Object[] args
)
public static function Concat (
	... args : Object[]
) : String
Not applicable.

Parameters

args

An Object array.

Return Value

The concatenated String representations of the values of the elements in args.

Exception typeCondition

ArgumentNullException

args is a null reference (Nothing in Visual Basic).

OutOfMemoryException

Out of memory.

An Empty string 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 ConcatTest {
    public static void Main() {

        // 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 in the objects is called
        Console.WriteLine(string.Concat(o));
    }
}

// imagine these test classes are full-fledged objects...
class Test1 {
}

class Test2 {
}

import System.*;

public class ConcatTest
{
    public static void main(String[] args)
    {
        // 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, (Int32)i, t2, s };
        // concatenate the objects together as a string. To do this,
        // the ToString method in the objects is called
        Console.WriteLine(String.Concat(o));
    } //main
} //ConcatTest

// imagine these test classes are full-fledged objects...
class Test1
{
} //Test1

class Test2
{
} //Test2

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