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.

String.Concat Method (String, String)

Concatenates two specified instances of String.

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

public static string Concat (
	string str0,
	string str1
)
public static String Concat (
	String str0, 
	String str1
)
public static function Concat (
	str0 : String, 
	str1 : String
) : String

Parameters

str0

The first String.

str1

The second String.

Return Value

The concatenation of str0 and str1.

An Empty string is used in place of any null argument.

The following code example concatenates a person's first, middle, and last name.

using System;

public class ConcatTest {
    public static void Main() {

        // we want to simply quickly add this person's name together
        string fName = "Simon";
        string mName = "Jake";
        string lName = "Harrows";

        // because we want a name to appear with a space in between each name, 
        // put a space on the front of the middle, and last name, allowing for
        // the fact that a space may already be there
        mName = " " + mName.Trim();
        lName = " " + lName.Trim();

        // this line simply concatenates the two strings
        Console.WriteLine("Welcome to this page, '{0}'!", string.Concat( string.Concat(fName, mName), lName ) );
    }
}

import System.*;

public class ConcatTest
{
    public static void main(String[] args)
    {
        // we want to simply quickly add this person's name together
        String fName = "Simon";
        String mName = "Jake";
        String lName = "Harrows";

        // because we want a name to appear with a space in between each name, 
        // put a space on the front of the middle, and last name, allowing for
        // the fact that a space may already be there
        mName = " " + mName.Trim();
        lName = " " + lName.Trim();

        // this line simply concatenates the two strings
        Console.WriteLine("Welcome to this page, '{0}'!", 
            String.Concat(String.Concat(fName, mName), lName));
    } //main
} //ConcatTest

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

Show:
© 2014 Microsoft