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

Answer Posted / ankur prasad gupta

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

Is This Answer Correct ?    19 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which of the following operations can you not perform on an ado.net dataset?

752


What is state c#?

624


To allow an element to be accessed using a unique key which .NET collection class is used ?

842


Explain About friend and Protected friend

698


What is string concatenation?

680


What is the difference between delegates and events in c#?

668


Why do we use static methods in c#?

754


Can arraylist store different data types in c#?

683


What is difference between string and stringbuilder in c#?

666


What is ado net in c#?

682


Define an abstract class?

682


Can bool be null c#?

677


What is generic method in c#?

687


Is c# a strongly-typed language?

724


Why is lazy loading?

668