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

What is the difference between read and readline in c#?

736


What is the namespace for datatable in c#?

748


What does it mean?

747


What is a private method in c#?

712


List the difference between interface and abstract class?

669


What is signature c#?

688


What is the differences between datagrid, datalist and repeater in .net?

736


What is the advantage of static class in c#?

722


Explain how do you directly call a native function exported from a dll?

724


List some of the classes used by system.data namespace?

632


List some of the basic string operation?

721


What are the different types of classes in c#?

721


What are primitive types in c#?

753


What is difference between C# and VB.NET?

794


Explain the difference between a Private Assembly and a Shared Assembly

750