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

what are some characteristics of an array?

716


Is string passed by reference in c#?

694


What is a partial class. Give an example?

698


What are types in c#?

678


What is tryparse c#?

710


how can one use hcl and c sharp together?

1776


What is firstordefault c#?

729


What are annotations in c#?

709


How garbage collection deals with circular references.

630


When would you use generics in your code c#?

675


What is difference between ienumerable and list in c#?

641


What floating point types is supported in C#?

784


How do you determine whether a string represents a numeric value?

716


What is difference between comparable and comparator?

654


Difference between directcast and ctype.

747