You need to perform a repeated string manipulation, and you want to optimize performance.
Use the System.Text.StringBuilder class to perform your string operations, and convert the final result into a string by calling ToString.
Ordinary .NET strings are immutable. Changing just a single character causes the whole string to be thrown away and a new string to be created.
The StringBuilder class represents a buffer of characters that can be directly modified. These direct modifications are faster than repeatedly generating a new String object. However, using the StringBuilder might introduce a small overhead because you need to copy the string into the StringBuilder before performing ...