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 is strong name assembly?
Why do we need collections in c#?
What are the Types of compatabilities and explain them
Explain the difference between class and interface in .net?
Can hashset contain duplicates c#?
What is the difference between “out” and “ref” parameters in c#?
Explain about Error handling and how this is done
What are winforms in c#?
What is token in c#?
What is the importance of closing an ado.net application?
What is dll in c#?
What is the delegate in c#?
I want to print "Hello" even before main() is executed. How will you achieve that?
How do you declare a method in c#?
What are strong name assemblies?