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

Answer Posted / akash

Both the String and StringBuilder class are used to store
strings. One exception is when we change the value in the
string it will create a new String object is creating in
memory and assign the new value.

eg: String name = "Sundar";

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

eg: String name = "Sundar Rahul";

But StringBuilder class occupies the same space even if you
change the value.

StringBuilder gives you better performance than String
class when you perform string manipulations like string
concatenation.

You can use StringBuilder's Append() method to use
concatenation and for String use "+".

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between new and override in c#?

453


What is the difference between var and dynamic types in c# 4.0?

507


What is xml serializer?

492


What is parsing?

527


Can destructors have access modifiers?

562






What is toint32 c#?

618


What is the difference between dynamic and var in c#?

457


What are the 3 different types of arrays?

559


What is the keyword used to prevent a class from being inherited by another class?

663


What is a partial class in c#?

485


Define Final Class in C#

542


Is java better than c sharp?

510


Can a sealed class be used as a base class?

527


What is Asynchronous call and how it can be implemented using delegates?

566


What do you mean by parsing and how to parse a date time string in c#?

517