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

Is array ienumerable c#?

680


Give an example to show for hiding base class methods?

646


Is c# static or dynamic?

723


What framework is used for performance testing/load testing?

1725


What are scriptable objects?

713


Explain circular reference in c#?

756


How many digits is a 32 bit number?

689


What is immutable in C#?

791


How do I make a dll in c#?

702


What is an enumerator c#?

724


What is the do while loop code?

699


what is boxing and unboxing?can we initialize unboxing directly?

708


What is an interface class in c#?

759


what is c# command?

735


Which are access modifiers available in c#?

735