Difference Between String And StringBuilder Using in Asp.Net C#


Difference Between String And StringBuilder 



S.No
         
               String

         
               StringBuilder
1It is Immutable.
It is Mutable.
2String Using System NameSpaces.
StringBuilder Using System.Text Namespaces.
3Once Create String Object We Cannot Modify.Once  Create String Builder Object We Can Perform Any Operation .
e.g Insert,Replace,Append.
4String Cannot  Append Keyword.
StringBuilder  Can  Append Keyword.

5
String is Slower Than StringBuilder Because Create New Instance for Every Time.

e.g 
        string a = "1";
        string b = "2";
        string c =a+b;

StringBuilder is Faster Than String Because Create One Instance for Every Time

e.g 

StringBuilder S= new StringBuilder("");
S.Append("");
S.Append("test ");
string c = S.ToString();






0 comments:

Post a Comment