WHAT IS THE DIFFERENCE BETWEEN STRING AND STRING BUILDER ?
Answer Posted / raviraj
String and String Builder class shows resemblance in terms
of values they accept(that contain series of haracters).But
the thing that distinguishes them is that string is
immutable .Immutable in the sense it will create a new copy
of memory whenever a new string is concatenated to the
existing string variable That means the existing memory is
deleted and replaced by the new memory.Whereas
Stringbuilder is mutable whenever we append a new string to
the existing string variable using append method the memory
containing the original string is extended to contain the
new string as well i.e, it won`t replace it with new memory
allocation.Hence performing string concatenations within
the same variable in the string class variables will affect
their performance.
| Is This Answer Correct ? | 17 Yes | 0 No |
Post New Answer View All Answers
What is the do while loop code?
What is boxing in c#?
What do you mean by string objects are immutable?
Is javascript harder than c#?
Why linq is having select clause at the end?
How does c# generics and c++ templates compare?
How many bytes is an int?
What is a linked list c#?
What is the purpose of static?
What is public or shared assemblies ?
How does insertion sort work?
what is inheritance and an example in vb.net and c# of when you might use it?
What is file extension of webservices?
Explain About delegates
Explain the difference between arraylist and array and in c#?