C# String Concat(Object[]) Array

Description

String Concat(Object[]) concatenates the string representations of the elements in a specified Object array.

Syntax

String.Concat(Object[]) has the following syntax.


public static string Concat(
  params Object[] args
)

Parameters

String.Concat(Object[]) has the following parameters.

  • args - An object array that contains the elements to concatenate.

Returns

String.Concat(Object[]) method returns The concatenated string representations of the values of the elements in args.

Example

The following example demonstrates the use of the Concat method with an Object array.


/*  w ww .j  a  v  a 2s  .  c o m*/
using System;

public class ConcatTest {
    public static void Main() {
        Test1 t1 = new Test1();
        Test2 t2 = new Test2();
        int i = 16;
        string s = "java2s.com";

        object [] o = { t1, i, t2, s };

        Console.WriteLine(string.Concat(o));
    }
}

class Test1 {
}

class Test2 {
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version