This article illustrates the different techniques to concatenate integers to a string in C#.

Since the string is immutable in C#, you can’t append any characters to it. However, you can create a new instance of the string with desired characters appended to it. This post provides an overview of few available alternatives to accomplish this.

1. Using + operator

A simple solution to concatenate an integer to a string is using the + operator. The following sample illustrates its usage.

Download  Run Code

2. Using string.Concat() method

The String class provides an overload of the Concat() method that accepts an object. A call to the + operator translates to the string.Concat() method, when at-least one operand is a string. You can directly invoke the string.Concat() method, as shown below:

Download  Run Code

3. Using string.Format() method

You can also use the string.Format() method to insert a value into a string. The following code example demonstrates how to invoke the String.Format() method to concatenate an integer to a string.

Download  Run Code

That’s all about concatenating integers to string in C#.