C# String Concat(Object)

Description

String Concat(Object) creates the string representation of a specified object.

Syntax

String.Concat(Object) has the following syntax.


public static string Concat(
  Object arg0
)

Parameters

String.Concat(Object) has the following parameters.

  • arg0 - The object to represent, or null.

Returns

String.Concat(Object) method returns The string representation of the value of arg0, or String.Empty if arg0 is null.

Example

The following example demonstrates the Concat method.


/* www  .  ja  v  a 2 s  .  c  o m*/
using System;

class stringConcat5 {
    public static void Main() {
        int i = -123;
        Object o = i;
        Object[] objs = new Object[] {-123, -456, -789};
    
        Console.WriteLine(String.Concat(o));
        Console.WriteLine(String.Concat(o, o));
        Console.WriteLine(String.Concat(o, o, o));
    
        Console.WriteLine(String.Concat(o, o, o, o));
        Console.WriteLine(String.Concat(o, o, o, o, o));
    
        Console.WriteLine(String.Concat(objs));
    }
}

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