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

ProgrammingServer Side ProgrammingCsharp

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!
raja
Published on 11-Sep-2018 12:31:07
Advertisements