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
Can abstract class have private constructor c#?
What is int64 in c#?
What is the advantage of singleton class?
What is the components of window?
What does m mean in decimal c#?
Can you specify nested classes as partial classes?
What is a static in c#?
What is a console in c#?
How do I unload an application domain?
Why constructor is used in c#?
What is a hash table c#?
Can partial class be inherited?
is it possible to access a remote web service Without UDDI?
What is type cast in C#?
What is the data type for bit in c#?