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
Can mvc be used for desktop applications?
How do I open the console?
Is static thread safe?
What is bit in c#?
What is the difference between an application domain and a process?
What does the parsefloat function do?
What is instantiating a class?
What is difference between association, aggregation and inheritance relationships?
What is difference between asp net and c# net?
Why do canadians say zed?
What is lastindexof c#?
Define multicast delegate in c#?
What is binding in c#?
What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?
What is private in c#?