C# String Concat(String, String)

Description

String Concat(String, String) concatenates two specified instances of String.

Syntax

String.Concat(String, String) has the following syntax.


public static string Concat(
  string str0,
  string str1
)

Parameters

String.Concat(String, String) has the following parameters.

  • str0 - The first string to concatenate.
  • str1 - The second string to concatenate.

Returns

String.Concat(String, String) method returns The concatenation of str0 and str1.

Example

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


/*from  ww w.  j a v  a 2  s .co  m*/
using System;

public class ConcatTest {
    public static void Main() {
        string fName = "A";
        string mName = "B";
        string lName = "C";

        Console.WriteLine(string.Concat( string.Concat(fName, mName), lName ) );
    }
}

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