What is the Main difference between String and
StringBuilder and why do we use StringBuilder.

Answer Posted / shaveen kaushal

Difference..
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, Stringbuilder object is used.
4.Insertion is done on the existing string.
5.Usage of StringBuilder is more efficient in case large
amounts of string manipulations have to be performed

Regards
Sridhar R
Nothing is illegal, Until You Get Caught

Is This Answer Correct ?    39 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string concatenation?

678


What is dictionary class in c#?

672


Is javascript harder than c#?

697


Explain a MSIL ? Why is it appreciated by all developers?

834


What is difference between yielding and sleeping?

643


Are string objects mutable or immutable?

707


What are the different types of constructors in c#?

803


Give some examples of commonly used i/o classes?

693


How do you concatenate in c#?

681


What is the use of ienumerable?

654


What is throw in c#?

688


What is monitor in C#?

782


Difference between call by value and call by reference in C#?

751


What is the difference between structure and class in c#?

687


Define c# delegate?

753