What is the difference between “System.String” and “System.StringBuilder” class?


Both the classes perform the same function of storing a string value.

System.String is said to be immutable, the reason being when a value is assigned to the variable it is stored in the memory in a space and when the assigned value is changed, the new value is stored in a new place in the memory and the older instance is deleted.

Whereas System.StringBuilder is said to be mutable, the reason being even when the value is changed it is stored in the same memory space. The performance of StringBuilder is better than the String class.

One can concatenate strings in StringBuilder by using the method “Append()” whereas in String it can be achieved by using the sign “+=”.


Comments

Popular posts from this blog

jQuery Basics

What is the difference between a Page Layout and Master Page in SharePoint?

Accessing data from SharePoint 2010 to an ASP.NET application