What is the difference between System.String and
System.StringBuilder classes?
Answer Posted / shyam vishwakarma
String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Prasad";
By saying you cannot change the name object means you cannot
change the value in name object internally. When you change
the name object value to something else, a new String object
is creating in memory and assign the new value.
eg: name = "Prasad Reddy";
A new name object is creating in memory and the value
"Prasad Reddy" 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.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What can I create with c#?
What is difference between C# and VB.NET?
Is c# the same as d flat?
Why delegates are required?
What's difference between constants and static readonly?
What are actions in c#?
Wht executescaler method is used?
What is an array? Give the syntax for a single and multi-dimensional array?
Can var be null c#?
What is a private method in c#?
what are the different ways a method can be overloaded?
What is the difference between final finally and finalize in c#?
How big is an int in c#?
Why do we use stringbuilder in c#?
What does void do in c#?