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 a c sharp?
what are the differences between a class and structure
When was .net linq added?
What is razor view in c#?
Is datetime value type c#?
Why do we use yield in c#?
What is a multi line comment?
Why References are stored on heap and variables on stack?
List down the reason behind the usage of c# language.
What is use of private class in c#?
What is a type c#?
What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?
What is the default value of object in c#?
What does type safety mean?
What tool we have to use to install assembli in gac folder.