Export (0) Print
Expand All

String.Concat Method (String[])

Concatenates the elements of a specified String array.

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

public static string Concat (
	params string[] values
)
public static String Concat (
	String[] values
)
public static function Concat (
	... values : String[]
) : String

Parameters

values

An array of String instances.

Return Value

The concatenated elements of values.

Exception typeCondition

ArgumentNullException

values is a null reference (Nothing in Visual Basic).

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 a String array.

using System;

public class ConcatTest {
    public static void Main() {

        // make an array of strings. Note that we have included spaces
        string [] s = { "hello ", "and ", "welcome ", "to ", "this ", "demo! " };

        // put all the strings together
        Console.WriteLine(string.Concat(s));

        // sort the strings, and put them together
        Array.Sort(s);
        Console.WriteLine(string.Concat(s));
    }
}

import System.*;

public class ConcatTest
{
    public static void main(String[] args)
    {
        // make an array of strings. Note that we have included spaces
        String s[] =  { "hello ", "and ", "welcome ", "to ", "this ", "demo! " };
        // put all the strings together
        Console.WriteLine(String.Concat(s));
        // sort the strings, and put them together
        Array.Sort(s);
        Console.WriteLine(String.Concat(s));
    } //main
} //ConcatTest

import System;

public class ConcatTest {
    public static function Main() : void {

        // make an array of strings. Note that we have included spaces
        var s : String [] = [ "hello ", "and ", "welcome ", "to ", "this ", "demo! "];

        // put all the strings together
        Console.WriteLine(System.String.Concat(s));

        // sort the strings, and put them together
        System.Array.Sort(s);
        Console.WriteLine(System.String.Concat(s));
    }
}
ConcatTest.Main();

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft