Difference Between String And StringBuilder
S.No | String | StringBuilder |
1 | It is Immutable. |
It is Mutable.
|
2 | String Using System NameSpaces. |
StringBuilder Using System.Text Namespaces.
|
3 | Once Create String Object We Cannot Modify. | Once Create String Builder Object We Can Perform Any Operation . e.g Insert,Replace,Append. |
4 | String 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