What is the Main difference between String and
StringBuilder and why do we use StringBuilder.
Answer Posted / sandeep soni
String are Immutable (Not Modifiable). If you try to modify
the string it actually creates a new string and the old
string will be then ready for garbage collection.
StringBuilder when instantiated, creates a new string with
predefined capacity and upto that capacity it can
accodomate string without needing to create a new memory
location for the string....i mean it is modifiable and can
also grow as and when needed.
When the string needs to be modified frequently, preferably
use StringBuilder as its optimized for such situations.
Is This Answer Correct ? | 113 Yes | 11 No |
Post New Answer View All Answers
What is a scope in c#?
How to use reflection to call generic method?
Why do canadians say zed?
What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?
What is virtual class in C#?
What happens if you add duplicate elements to a set?
What is cts, clr?
Is array reference type in c#?
What's c# ?
What are delegates and why are they required?
What is the difference between values and reference types?
What are Namespaces?
What is the difference between var and dynamic types in c# 4.0?
Why singleton class is sealed?
What is delegates in c# and uses of delegates?