This post will discuss how to append a char to the end of a string in C#.

1. Using + operator

A simple solution to append a character to the end of a string is using the + operator. Here’s what the code would look like:

Download  Run Code

 
Alternatively, you can concatenate a character to the end of a string with the += operator.

Download  Run Code

 
Finally, to concatenate a character at the front of a string, do as follows:

Download  Run Code

2. Using StringBuilder

If you need to append a character multiple times to a string, consider using a StringBuilder. The idea is to convert the String object to StringBuilder, and use its Append() method to append each character to it. Finally, invoke the ToString() method to convert the StringBuilder back into a string. Note that the StringBuilder class is available under the System.Text namespace.

Download  Run Code

3. Using String.Insert() method

If you need to insert another string at a specified position in the given string, you can use the String.Insert() method. This method only accepts a string, and it is not overloaded for the character data type.

Download  Run Code

That’s all about appending a char to the end of a string in C#.