How to concatenate two strings in C#?


To concatenate two strings, use the String.Concat method.

Let’s say you want to concatenate two strings in C#, str1 and str2, then add it as arguments in the Concat method −

string str3 = string.Concat(str1, str2);

Example

The following is the example −

 Live Demo

using System;

class Program {
   static void Main() {

      string str1 = "Brad";
      string str2 = "Pitt";

      // Concat strings
      string str3 = string.Concat(str1, str2);
      Console.WriteLine(str3);
   }
}

Output

BradPitt

Updated on: 20-Jun-2020

652 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements