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

The + operator is used to concatenate two or more string objects in C#. This operator provides a simple and intuitive way to combine strings, making it one of the most commonly used string operations in C# programming.

Syntax

Following is the basic syntax for string concatenation using the + operator −

string result = string1 + string2;
string result = string1 + string2 + string3;

Using + Operator for String Concatenation

Example 1: Basic String Concatenation

using System;

class Program {
   static void Main() {
      string str1 = "Hello";
      string str2 = "World";
      string result = str1 + " " + str2;
      Console.WriteLine(result);
   }
}

The output of the above code is −

Hello World

Example 2: Concatenating Multiple Strings

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 + "!");
   }
}

The output of the above code is −

Welcome Henry and Jack!

Example 3: Concatenating Strings with Numbers

using System;

class Program {
   static void Main() {
      string name = "Alice";
      int age = 25;
      string message = "Name: " + name + ", Age: " + age;
      Console.WriteLine(message);
   }
}

The output of the above code is −

Name: Alice, Age: 25

Alternative String Concatenation Methods

Method Example Best For
+ Operator str1 + str2 Few strings, simple operations
String.Concat() String.Concat(str1, str2) Multiple strings, null safety
StringBuilder sb.Append(str1).Append(str2) Many concatenations, loops
String Interpolation $"{str1} {str2}" Readable formatting with variables

Conclusion

The + operator is the simplest and most intuitive way to concatenate strings in C#. It automatically converts non-string operands to strings and handles null values gracefully, making it ideal for basic string concatenation operations.

Updated on: 2026-03-17T07:04:35+05:30

685 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements