Difference between string and stringbuilder?
Answer Posted / vinodh kumar
Though string looks like mutable(the value can be changed once after initial value) but string is not mutable. Every time you modify the string a new object reference will be created and it will gets updated. StringBuilder is mutable.
In situations like you want to concat strings in loopings, we'll use StringBuilder.
In loops like for, for each, while, etc., using string for concatenation it will give negative performance.
Conclusion:
-----------
String is Immutable.
StringBuilder is Mutable. For performance reasons during concatenation operations in string in conditional looping statements we use StringBuilder.
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is concrete method in c#?
Define satellite Assembly in .NET?
What is a variable in c#?
Explain about WSDL
What is int16?
What is inheritance c#?
What are the different types of delegation?
What is difference between virtual and override in c#?
Which is the base class in c#?
What do you mean by jagged arrays in c#?
What is data binding c#?
What is window application in c#?
What is the difference between method and constructor in c#?
Is c# pass by reference?
How do you type a null character?