Wednesday, June 8, 2016

String vs. StringBuilder

StringBuilder performance better , won't keep create a new string in every loop.

StringBuilder can be used where more than four or more string concatenations take place.
String to do some manipulation (remove and replace a part from the string)

String
StringBuilder
immutable
mutable
Performance slow because every time will create new instance
Performance high because it will use same instance of object to perform any action
String belongs to System namespace
Stringbuilder belongs to System.Text namespace

No comments:

Post a Comment