C# add string
last modified October 5, 2026
This article shows how to add, or concatenate, strings in C#. A string is an immutable sequence of Unicode characters, so concatenation always produces a new string and leaves the original instances unchanged.
The language and the base class library offer several ways to join strings:
- the
+and+=operators - the
string.Concatmethod - the
string.Joinmethod - the
StringBuilderclass - string interpolation
- the
string.Formatmethod
Adding strings with the + operator
The simplest way to concatenate strings is the + operator. The
same operator also adds numbers, so it is overloaded: the compiler chooses the
string overload whenever one of the operands is a string.
var a = "an old"; var b = " falcon"; var c = a + b; Console.WriteLine(c);
The example joins two strings into a new one and prints the result.
$ dotnet run an old falcon
The compound assignment operator += appends the right operand to
an existing string variable.
var msg = "There are "; msg += "three falcons "; msg += "in the sky"; Console.WriteLine(msg);
Each += creates a new string from the old value and the appended
text, and then stores it back in msg.
$ dotnet run There are three falcons in the sky
Adding strings with string.Concat
The string.Concat method concatenates one or more strings. It
has overloads that accept two strings, three strings, four strings, an array of
strings, and an IEnumerable<string>.
var a = "an old";
var b = " eagle";
var c = string.Concat(a, b);
Console.WriteLine(c);
Console.WriteLine(string.Concat("one", " ", "two", " ", "three"));
The first call joins two variables. The second call uses the four-string overload to build a sentence from separate parts.
$ dotnet run an old eagle one two three
Adding strings with string.Join
The string.Join method concatenates the elements of an array or
a collection, placing a separator between them. Unlike Concat, it
also inserts the delimiter, which is a common task when building comma- or
space-separated text.
string[] words = ["There", "are", "two", "owls", "on", "the", "tree"];
var msg = string.Join(" ", words);
Console.WriteLine(msg);
The example joins the elements of an array with a single space. The array is created with a collection expression, which is available in C# 12 and later.
$ dotnet run There are two owls on the tree
Adding strings with StringBuilder
StringBuilder represents a mutable sequence of characters. Its
Append method adds text to the same buffer instead of allocating a
new string for every step, which makes it the preferred choice when many pieces
are joined in a loop or when the final size is not known in advance.
using System.Text;
var builder = new StringBuilder("There");
builder.Append(" are");
builder.Append(" two");
builder.Append(" falcons");
builder.Append(" in");
builder.Append(" the");
builder.Append(" sky");
Console.WriteLine(builder.ToString());
The example builds a sentence from seven parts. Only the final
ToString call creates the completed string.
$ dotnet run There are two falcons in the sky
Adding strings with string interpolation
An interpolated string starts with the $ character. Expressions
placed inside curly brackets are evaluated and replaced by their string
representation when the string is created.
var w1 = "three";
var w2 = "owls";
var msg = $"There are {w1} {w2} on the tree";
Console.WriteLine(msg);
Interpolated strings are the most readable way to combine literal text with values, and the compiler can format the arguments efficiently.
$ dotnet run There are three owls on the tree
Adding strings with string.Format
The string.Format method replaces numbered placeholders in a
composite format string with the string representations of the supplied
arguments. Interpolation is usually clearer, but string.Format
remains useful when the format string is stored or localized separately from
the code.
var w1 = "three";
var w2 = "owls";
var msg = string.Format("There are {0} {1} on the tree", w1, w2);
Console.WriteLine(msg);
Placeholder {0} refers to the first argument and
{1} to the second. Both this example and the interpolation example
produce the same text.
$ dotnet run There are three owls on the tree
Which approach to choose
Use the + operator or interpolation for a small, fixed number
of strings, because the compiler turns such expressions into a single
string.Concat call. Use string.Join when a separator
is needed between the parts, and StringBuilder when many
concatenations happen in a loop, since each + operation there
allocates a new string and copies the accumulated text.
Source
Strings and string literals
StringBuilder Class
In this article we have shown several ways to add strings in C#.
Author
List all C# tutorials.