| Sr No. |
Sting |
StringBuilder |
| 1. |
String is immutable. |
StringBuilder is mutable in C#. |
| 2. |
We can't modify it after it is created. It creates a new object of string type in memory if we perform any operation in that String variable |
This means that if an operation is performed on the string, it will not create a new instance every time. With that, it will not create new space in memory, unlike Strings. |
| 3. |
It is slow because all time create new instance |
It is fast because of same instance using when any operation is performed |
| 4. |
The namespace used System |
The namespace used System.Text |
No comments:
Post a Comment