What\'s the best string concatenation method using C#?

Answer

The StringBuilder.Append() method is much better than using the + operator. But I've found that, when the concatenations are less than 1000, String.Join() is even more efficient than StringBuilder.

StringBuilder sb =newStringBuilder();
sb.Append(someString);

The only problem with String.Join is that you have to concatenate the strings with a common delimiter.

string key =String.Join("_",newString[]{"Customers_Contacts", customerID, database,SessionID});

All string Questions

Ask your interview questions on string

Write Your comment or Questions if you want the answers on string from string Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---