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 to implement on my class Finalize or IDisposable
What is the delegates in c#?
What is a partial class. Give an example?
What are get and set in c#?
What is _viewstart cshtml?
Which is better python or c#?
What is an array of arrays called?
Explain the process of inheriting a class into another class?
What language is c# similar to?
What is predicate c#?
What are the 4 pillars of any object oriented programming language?
What do you mean by hashtable c#?
What are value types in c#?
Which property do we set on a Combo Box to display data on it prior to setting the DataSource ?
What is stringreader in c#?