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

1. Using Concatenation Operator

A simple solution to concatenate multiple integers together to get a string is using the String.Concat() method. This is the preferred method over the string concatenation operator +, which can join only string instances and requires casting to concatenate integers.

Download  Run Code

2. Using String.Format() method

Alternatively, you can use the String.Format() method to concatenate multiple integers in C#. To illustrate, consider the following code, which joins two integers.

Download  Run Code

3. Using String Interpolation

The String interpolation ($) provides a convenient syntax for concatenating multiple values together to form a string. This is available since C# 6 and can be used as follows to concatenate two integers.

Download  Run Code

4. Using StringBuilder

The StringBuilder class is recommended for concatenating multiple values together in C#, as it outperforms all other methods. It has the Append() method, which is overloaded to accept any data type.

Download  Run Code

That’s all about concatenating multiple integers to get a new string in C#.