Knowledge Management Banner

Knowledge Management Banner

C# : String Vs String Builder : Part 25

String String Builder
string UserString = "C#" StringBuilder UserString = new StringBuilder("C#")
UserString+="video"; UserString.append("video");
UserString+="tutorial"; UserString.append("tutorial");
UserString+="for"; UserString.append("for");
UserString+="begineers"; UserString.append("begineers");
  • Refer image below
Using system.string
  • In this when every time a string is appended a new object is created in new memory location and the previous object remains as it is.
Using system.StringBuilder
  • In this when the string is appended, no new memory location is created, the changes take place in same memory location.

No comments

Powered by Blogger.