What is the operator that concatenates two or more string objects in C#?


Use operator + to concatenate two or more string objects.

Set the first string object.

char[] c1 = { 'H', 'e', 'n', 'r', 'y' };
string str1 = new string(c1);

Now, set the second string object.

char[] c2 = { 'J', 'a', 'c', 'k' };
string str2 = new string(c2);

Now display the concatenated strings using + operator.

Example

 Live Demo

using System.Text;
using System;
class Program {
   static void Main() {
      char[] c1 = { 'H', 'e', 'n', 'r', 'y' };
      string str1 = new string(c1);
      char[] c2 = { 'J', 'a', 'c', 'k' };
      string str2 = new string(c2);
      Console.WriteLine("Welcome " + str1 + " and " + str2 + "!");
   }
}

Output

Welcome Henry and Jack!

Updated on: 22-Jun-2020

549 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements