From this Article you can know which is the best way in performance to concatenate a string.
we can concatenate a string in two ways.
1)by using String
2)by using StringBuilder class.
1)String Explanation:Normally two strings can concatenate as below
String str1="A";
String str2="B";
String str3=str1+str2;
it is a simple way if there is less concatenation.if you want to concatenate string n number of times by using forloop it takes time to complete entire loop and result for output.
2)StringBuilder is the best way to concatenate string.it doesnt take any time to concatenate string compare to normal string concatenate.you can concanate a string by using Append() as follows
example:
StringBuilder sb1 = new StringBuilder("Shakeer");
sb1.Append("Hussain");
Console.WriteLine(sb1.ToString());
output:ShakeerHussain
To see which is the best way to use String and StringBuilder see Below coding and OutPut:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace diffString
{
class Program
{
static void Main(string[] args)
{
string str = "";
Console.WriteLine("Starting time for concatenate string =" + System.DateTime.Now.ToLongTimeString());
for (int i = 0; i < 20000; i++)
{
str +=i.ToString ();
}
Console.WriteLine("Ending time for concatenate string =" + System.DateTime.Now.ToLongTimeString());
Console.WriteLine("");
Console.WriteLine("Starting time for concatenate string with stringbuilder =" + System.DateTime.Now.ToLongTimeString());
for (int i = 0; i < 20000; i++)
{
StringBuilder sb = new StringBuilder("shakeer");
sb.Append(i.ToString ());
}
Console.WriteLine("Ending time for concatenate string with stringbuilder =" + System.DateTime.Now.ToLongTimeString());
Console.Read();
}
}
}
OutPut:

In the above output observe that it takes 4 seconds to concatenate norma String.By using StringBuilder Class it does not take any time concatenate string.
So use StringBuilder is the better way to concatenate String.
Note:if you are using StringBuilder Class you have to add a NameSpace Using System.Io