Question:
What is the difference between System.String and System.StringBuilder classes?
Answer:
System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. Source: CoolInterview.com
String is immutable.A new object is create if a string needs to be modified. While string builder object can be modified without creating a new object. stringbuilder class offers various methods like replace etc. Source: CoolInterview.com
Answered by: psingla | Date: 3/25/2010
| Contact psingla
IN System.String 1.String is built in class in .net base classes. 2.In this we can do all the string operation like substring,strcpy etc but cant do editing .so thats called immutable. 3.System.StringBuilder class have ability of append function that not available in Sting class Source: CoolInterview.com
Answered by: Ankur Bhutani | Date: 4/1/2010
| Contact Ankur Bhutani
String.. 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 Source: CoolInterview.com
Answered by: subbarao | Date: 4/3/2010
| Contact subbarao
System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Source: CoolInterview.com
Answered by: anurag mishra | Date: 4/6/2010
| Contact anurag mishra
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|