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
What is strong name assembly?
Are c# generics the same as c++ templates?
What issues can be faced while delivering code?
What is command object in c#?
Can scriptable objects have methods?
Explain About delegates
What are the differences between a class and a struct?
When was .net linq added?
What is threading in c# with example?
What is the .NET collection class that allows an element to be accessed using a unique key?
How to get the sum of last 3 items in a list using lambda expressions?
What are the boolean data types in c#?
Is array a collection c#?
Why is main static in c#?
What is sqldatareader c#?