Gautam Kumar
What are the differences between System.String and System.Text.StringBuilder classes?
By Gautam Kumar in C# on Nov 19 2013
  • Divendra Ojha
    Jul, 2014 17

    String is immutable. Immutable means once we create string object we cannot modify. Any operation like insert, replace or append happened to change string simply it will discard the old value and it will create new instance in memory to hold the new value.Example: string str = "dev"; onestr = "endra"; str = "help"; String builder is mutable it means once we create string builder object we can perform any operation like insert, replace or append without creating new instance for every time.Example: StringBuilder sb = new StringBuilder(""); sb.Append("hi"); sb.Append("test "); string str = sb.ToString();

    • 0
  • Gautam Kumar
    Nov, 2013 19

    System.String is immutable. When we modify the value of a string variable then a new memory is allocated to the new value and the previous memory allocation released. System.StringBuilder was designed to have concept of a mutable string where a variety of operations can be performed without allocation separate memory location for the modified string.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS