5 July 2013

Difference between string and stringbuilder in c#


String:

1.Its a class used to handle strings. 

2.we say "Strings are immutable".
3.Here concatenation is used to combine two strings. 
4.String object is used to concatenate two strings. 
5.The first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted 
6.. system.string is non updatable. 

stringbuilder:


1. system.stringbuilder is updateble. 

2.Insertion is done on the existing string. 
3.string builder is faster than the string object. 
4.String builder is more efficient in case large amount of string operations have to be perform. 
5.String builder is mutable means we can able to re size the memory size 
6.System.stringbuilder is used to dynamic strings 


No comments:

Post a Comment