String.Concat Method (Object[])

Concatenates the String representations of the elements in a specified Object array.

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

'Declaration
Public Shared Function Concat ( _
	ParamArray args As Object() _
) As String
'Usage
Dim args As Object()
Dim returnValue As String

returnValue = String.Concat(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.

Imports System



Public Class ConcatTest
    
    Public Shared Sub Main()
        Dim t1 As New Test1()
        Dim t2 As New Test2()
        Dim i As Integer = 16
        Dim s As String = "Demonstration"
        Dim o As Object() = {t1, i, t2, s}
        
        ' create a group of objects
        
        ' place the objects in an array
        
        ' concatenate the objects together as a string. To do this,
        ' the ToString method in the objects is called
        Console.WriteLine(String.Concat(o))
    End Sub 'Main
End Class 'ConcatTest


' imagine these test classes are full-fledged objects...
Class Test1
End Class 'Test1

Class Test2
End 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

ADD
Show: