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

Answer Posted / sundarchum

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 ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a generic method?

485


How many types of inheritance are there in c#?

471


What operators can be used to cast from one reference type to another without the risk of throwing an exception?

512


Why dataset is used in c#?

509


Ho we can see assembly information?

518






What is the difference between abstract class and interface in c#?

486


What is difference between C# and VB.NET?

512


Explain how do I convert a string to an int in c#?

508


Explain the use of Mutex in C#?

556


Are cao stateful in nature?

471


What is the difference between Static, Const and read only?

534


How do you escape in c#?

496


For methods inside the interface why can’t you specify the accessibility modifier?

545


What is cookies c#?

483


What is selector c#?

507