What’s the difference between System.String and System.StringBuilder classes?

 Posted by Charugoel on 2/4/2009 | Category: ASP.NET Interview questions | Views: 7613

System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.Append Keyword is used in System.StringBuilder but not in System.String.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Himali on: 1/5/2013 | Points: 10
sytem.string is immutable it means if we r performing
string manipulations new memory is allocated each time
eg:string a=dev; a=arora; in this case new memory is
created a=arora and previously a=dev wil be deleted.so
major impact on performance but string builder is mutable
so same memory wil be updated for the same so good

1.Its a class used to handle strings.
2.Here concatenation is used to combine two strings.
3.String object is used to concatenate two strings.
4.The first string is combined to the other string by
creating a new copy in the memory as a string object, and
then the old
string is deleted
5.we say "Strings are immutable".

String Builder..
1.This is also the class used to handle strings.
2.Here Append method is used.
3.Here, String builder object is used.
4.Insertion is done on the existing string.
5.Usage of String Builder is more efficient in case large
amounts of string manipulations have to be performed

Login to post response