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
Describe the types of comments in c#?
Is std :: string null terminated?
What is inumerable?
Is a c# interface the same as a c++ abstract class?
What is the difference between internal and protected in c#?
What is deadly diamond problem?
Why main is static in c#?
What will a loop recorder show?
How to use delegates with events?
windows c# using datagridview in edit form sql server
What is sqlcommand in c#?
What is xml document how do you open it?
What is the difference between overriding and overloading in systemverilog?
What is system predicate?
Is Multiple-inheritance supported by c#?