Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
1 out of 1 rated this helpful - Rate this topic

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
Not applicable.

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).

OutOfMemoryException

Out of memory.

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 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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.