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
How to implement an object pool in c#.net.
What is a web service in c#?
What is escape character in c#?
Can we have two main methods in c#?
Why delegates are type safe?
What are predicates in c#?
Define multicast c# delegate?
What is datagridview in c#?
Do loops c#?
What is a framework in c#?
What is difference between for and foreach loop in c#?
What is the syntax for calling an overloaded constructor within a constructor?
What are the steps to make an assembly to public?
What is difference between struct and class in c#?
Why do we use yield in c#?