Difference between string and stringbuilder?
Answers were Sorted based on User's Feedback
Answer / dsr
string is immutable.String and StringBuffer both are
classes.stringbuffer is mutable.
Is This Answer Correct ? | 12 Yes | 2 No |
Answer / akash
using String
if u want to append the text then u prefer's this thing
string strTemp="a";
strTemp=strTemp+"jay";
But in case of StringBuilder
if u want to do the samething then u will get a append() function.
Is This Answer Correct ? | 6 Yes | 3 No |
Answer / 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 |
How to declare a property in a class?
Trace the O/p for a program on inheritance and Polymorphism. 3 classes A,B,C A with two methods public virtual SomeMethodA public virtual SomemoreMethodA B:A overide virtual SomeMethodA C:B new Method SomeMethodA override SomeMoreMethodA main method { b new instance of B b.SomeMethodA b.SomeMoreMethodA b1 new instance of C b1.SomeMethodA b1.SomeMoreMethodA }
What is the namespace for the thread class?
What is the use of partial methods?
What is private and shared assembly?
Is an interface a type c#?
If the original method is not static you can declare an override method to be static or not?
What is difference between ienumerable and list?
What is static and use of it?
3. Use layered architecture for coding. s.no name description 1 abc xxxxxxxxx 2 abc xxxxxxxxx 3 4 5 6 7 8 Select all Clear all Add Delete Name Description Save close
in object oriented programming, how would you describe encapsulation?
What is ac callback?