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...

Difference between string and stringbuilder?

Answer Posted / vinodh kumar

Though string looks like mutable(the value can be changed once after initial value) but string is not mutable. Every time you modify the string a new object reference will be created and it will gets updated. StringBuilder is mutable.

In situations like you want to concat strings in loopings, we'll use StringBuilder.

In loops like for, for each, while, etc., using string for concatenation it will give negative performance.

Conclusion:
-----------
String is Immutable.
StringBuilder is Mutable. For performance reasons during concatenation operations in string in conditional looping statements we use StringBuilder.
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If I want to override a method one of class A and in class b then how do you declare?

1389


Explain the features of an abstract class in net.

1022


What is state c#?

932


What is the difference between C# 3.5 and C# 4.0?

996


What is the purpose of dictionary in c#?

958


How do I make a dll in c#?

982


What is garbage collection? How to force garbage collector to run?

962


What is namespace explain with example?

916


How do I move from one form to another in c#?

935


Why is hashset faster?

1045


What is difference between a constant and read-only in C#?

1018


Explain About Web.config

1025


What is the delegates in c#?

960


Can a class be private in c#?

1040


What is lazy keyword in c#?

966