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

How does c# generics and c++ templates compare?

666


What is a jagged array?

701


What is fcl in c#?

669


Why do we need ienumerable in c#?

679


What is difference between array and collection in c#?

657


What are satellite assemblies?

725


How do I join one form to another in c#?

675


Is visual c# free?

688


What is bitwise operator in c#?

678


When should we use sealed class in c#?

678


Explain how obfuscator works in .net

748


What is a nested type. Give an example?

826


How do I do implement a trace and assert?

775


without modifying source code if we compile again, will it be generated MSIL again?

691


Can list contain duplicates c#?

671