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 can you achieve run time polymorphism in C#?

770


How the versioning applies to Assemblies or can you explain version numbers?

830


How do you define a predicate?

676


Explain About web methods and its various attributes

758


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

705


Describe two uses of the “using” statement during the operation of c#?

743


What does dbml mean in texting?

707


Can a string be null c#?

689


What is difference between the "throw" and "throw ex" in .net?

698


What is difference between method and function in c#?

677


What is hashmap in c#?

657


What is a lambda expression in c#?

1010


How are methods overloaded?

748


What is autopostback in c#?

698


How can it prevents DLL Hell assembly versioning in .NET?

778