What is the Main difference between String and
StringBuilder and why do we use StringBuilder.
Answer Posted / anandha kumar t
Both String and StringBuilder are classes used to
handle the strings.
The most common operation with a string is
concatenation. This activity has to be performed very
efficiently. When we use the "String" object to concatenate
two strings, the first string is combined to the other
string by creating a new copy in the memory as a string
object, and then the old string is deleted. This process is
a little long. Hence we say "Strings are immutable".
When we make use of the "StringBuilder" object, the
Append method is used. This means, an insertion is done on
the existing string. Operation on StringBuilder object is
faster than String operations, as the copy is done to the
same location. Usage of StringBuilder is more efficient in
case large amounts of string manipulations have to be performed.
Is This Answer Correct ? | 81 Yes | 16 No |
Post New Answer View All Answers
What is entity framework in c#?
What is a race condition?
What are synchronous and asynchronous operations?
What is appdomain in c#?
Is functional interface runnable?
write code for inserting and updating recoards in sql server database using connected architecture & records shoulds displayed in grid view ( use c# )
What is different between Implicit conversion and Explicit conversion in C#?
What are the advantages of using c#?
What is a string in c#?
Distinguish between the Debug class and Trace class with its functionality?
How do I do implement a trace?
What is lazy loading c#?
Is null in c#?
What's the difference between an integer and int?
What is data hiding in c#?