Friday 4 November 2016

String vs StringBuilder

String

String is Immutable.

Immutable means once we create an object we cannot modify. 

If we try to perform any operation like insert, replace or append on string it will simply discard the old value and it will create new instance in the memory to hold the new value.

String belongs to System Namespace.

Performance wise string is slow because it will create a new instance every time.



StringBuilder

StringBuilder is Mutable

Mutable means once we create StringBuilder object we can perform any operation like insert, replace or append without creating new instance every time.









Hope this information  helpful to you. Thank you for taking time to look at my blog. ----- Syed Sadiq Ali.      







No comments: