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
Are structs value types c#?
What is a console operator?
What is an ienumerable in c#?
How do I unload an application domain?
List down the different ide’s provided by microsoft for c# development.
Overloaded constructor will call default constructor internally?
Can we have 2 main methods in c#?
Can you create an instance of a static class?
Are c# destructors the same as c++ destructors?
Is overriding of a function possible in the same class?
Can a struct inherit from another struct or class in c#?
Is equal in c#?
Which namespaces are necessary to create a localized application?
What is a di class?
Can abstract class be instantiated c#?