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
Describe ways of cleaning up objects in c#.
what is difference between is and as operators in c#?
Does c# support try-catch-finally blocks?
What are Uses of CLR
What is difference between c sharp and c#?
Can you declare struct members as protected?
How Is The Dll Hell Problem Solved In .net?
What is .dbml file?
How do I join one form to another in c#?
What is Implicit conversion in C#?
What is ado c#?
In c#, what will happen if you do not explicitly provide a constructor for a class?
Explain the difference between “constant” and “read-only” variables used in c#?
How do partial classes work in c#?
What is arraylist class in c#?