C# String Concat(String[])

Description

String Concat(String[]) concatenates the elements of a specified String array.

Syntax

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


public static string Concat(
  params string[] values
)

Parameters

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

  • values - An array of string instances.

Returns

String.Concat(String[]) method returns The concatenated elements of values.

Example

The following example demonstrates the use of the Concat method with a String array.


//  w  w  w .  jav  a2 s  .co m
using System;

public class ConcatTest {
    public static void Main() {
        string [] s = { "hello ", "and ", "welcome ", "to ", "this ", "demo! " };

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

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