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 "Rengan nathan" 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.
i hope this may help u

Is This Answer Correct ?    20 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need indexers in c#?

640


How many types of variables are there in c#?

690


How to get the sum of last 3 items in a list using lambda expressions?

692


What is a variable in c#?

676


What is firstordefault c#?

715


What do you mean by serialization in .NET?

716


What is cosole application?

767


What are the different ways of method can be overloaded?

653


What are the features of c#?

686


What are the namespace level elements?

667


Are tuples mutable c#?

645


What are value types in c#?

676


What is function c#?

663


What tool we have to use to install assembli in gac folder.

677


Does c# support parameterized properties?

695