WHAT IS THE DIFFERENCE BETWEEN STRING AND STRING BUILDER ?

Answer Posted / stanly jose

String and StringBuilder class stores strings. But you
cannot change a String object after creating one.
eg: String name = "Stanly";
you wan to change the same string name to
eg: name = "Stanly Jose";
then a new String object is creating in memory and assign
the new value as "Stanly Jose".
(A new name object is creating in memory and the
value "Stanly Jose" is assinging to the newly created
space.)

But StringBuilder class occupies the same space even if you
change the value.

If you are doing string concatenation StringBuilder class
is far better in performance than String class.

You can use StringBuilder's Append() method to use
concatenation.

note:
system.string is immutable,system.stringbuilder was
designed with the purpose of having a mutable string where
a variety of operations can be performed.

Is This Answer Correct ?    14 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are constructors inherited c#?

664


What is difference between method and function in c#?

655


What are constructors in c#?

713


What is difference between an reference type and value type in C#?

789


Does c# provide copy constructor?

759


what is IDisposal interface,IComparable,IEquatable,IFormatable

741


What is platform independence"?

730


What is public, private, protected, internal and internal protected?

705


What are the fundamental differences between value types and reference types?

759


How many bytes is a char c#?

658


What is datareader c#?

666


What is an array class?

752


Write a sample code to write the contents to text file in c#?

654


What does mean before a string in c#?

697


How can I use .NET components from COM programs?

674