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


Please Help Members By Posting Answers For Below Questions

Please explain value types and reference types used in c#?

567


Illustrate the differences between the system.array.copyto() and system.array.clone()?

589


What is the usage of OLE?

666


Wht executescaler method is used?

616


Which is executed if an exception has not occurred?

598






What is predicate c#?

626


What is datatable and dataset in c#?

555


What is an array class?

627


How can I make sure my c# classes will interoperate with other .net languages?

604


What is difference between iqueryable and ienumerable in c#?

528


Are string objects mutable or immutable?

611


What is a factory in c#?

562


What is using keyword in C#?

669


Are c# constructors the same as c++ constructors?

617


How do I run managed code in a process?

609