What is the Difference Between string and System.Text.StringBuilder?

 Posted by Lakhangarg on 8/18/2009 | Category: ASP.NET Interview questions | Views: 3701

System.Text.StringBuilder strTest=new System.Text.StringBuilder();
Strings are immutable. immutable means every time we alter the string a new object is created. hence lower the performance. while stringBuilder are mutable. so it increase the performance where we need to perform altered, insert and remove operations. But it is not recommended to use StringBuilder always. for small string where you need to perform less operation then use string
and in case of large string and more operation use StringBuilder.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response