Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What?s the difference between System.String and
System.StringBuilder classes?

Answer Posted / sandeep joshi

String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Joshi";
By saying you cannot change the name object means you
cannot change the value in name object internally. When you
change the name object value to something else, a new
String object is creating in memory and assign the new
value.

eg: name = "Sandeep Joshi";

A new name object is creating in memory and the
value "Sandeep Joshi" is assinging to the newly created
space.

But StringBuilder class occupies the same space even if you
change the value.
If you are doing string concatenation StringBuilder class
is far better in performance than String class.
You can use StringBuilder's Append() method to use
concatenation and also use Reverse,Remove methods.
Usually, String is immutable which means once you have the
content there you cannot change it. While StringBuilder is
mutable because it allows you to change the content you
have already placed.

Notice that a string allows you to change the content but
offcourse it creates a new string reference. For example,
all string methods return a new string and don't update the
same string variable.

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between value and reference type.

873


What is an abstract class c#?

842


what is the difference between interface and multiple interface?

983


What are desktop applications examples?

893


Write a C# program to find the Factorial of n

925


Explain what is copy constructor?

955


Can I call a virtual method from a constructor/destructor?

833


Are there functions in c#?

903


What is parameters in c#?

884


What is hash c#?

879


Is c# pass by value?

857


If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?

886


How to find the current application file path while runtime?

927


What is an int in c#?

860


What is difference between a type and class?

1066