Export (0) Print
Expand All

String.Concat Method (Object, Object, Object)

Concatenates the String representations of three specified objects.

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

public:
static String^ Concat (
	Object^ arg0, 
	Object^ arg1, 
	Object^ arg2
)
public static String Concat (
	Object arg0, 
	Object arg1, 
	Object arg2
)
public static function Concat (
	arg0 : Object, 
	arg1 : Object, 
	arg2 : Object
) : String
Not applicable.

Parameters

arg0

The first Object.

arg1

The second Object.

arg2

The third Object.

Return Value

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

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

The following code example demonstrates the Concat method.

using namespace System;
int main()
{
   int i = -123;
   Object^ o = i;
   array<Object^>^objs = { -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

ADD
Show:
© 2014 Microsoft