Interviews - C# Corner

Meenakshi Pillay
What are differences between system.stringbuilder and system.string?
By Meenakshi Pillay in ASP.NET onMar 27 2014
  • Sandeep Singh
    Sep, 2016 16

    1) String are fixed length where stringbuilder is just like variable length. At the time of declaration the given length is called limitation which is String. At the run-time increasing the size is called capacity which is StringBuilder.

    • 2
  • Gaurav Jain
    Jun, 2015 25

    The main difference is system.string is immutable and system.stringbuilder is a mutable. Usage of String Builder is more efficient in case large amounts of string manipulations. Performance wise string is slow because every time it will create new instance.

    • 2
  • Meenakshi Pillay
    Mar, 2014 27

    The main difference is system.string is immutable and system.stringbuilder is a mutable. Append keyword is used in string builder but not in system.string.
    Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.

    • 2
  • vartika tomar
    Jul, 2015 13

    system.string is immutable and we can,t change the size of string object while system.stringbuilder is mutable and we can change the size of stringbuilder class object.

    • 0
  • Munesh Sharma
    Oct, 2014 9

    http://www.aspdotnet-suresh.com/2013/11/difference-between-string-and-stringbuilder-csharp.html

    • 0
  • Roymon TP
    Oct, 2014 9

    System.string is immutable .ie it means when we do any operations on string object new object is created. system. String builder is mutable ,ie we can do various operations on the string, no new string object is created.

    • 0
  • Dileep Kumar Patel
    Apr, 2014 3

    The best example for understand to stringbulider and string :for String : string s = string.Empty; for (i = 0; i < 10; i ) {s = i.ToString() " "; }for stringbuilder : StringBuilder sb = new StringBuilder(); for (i = 0; i < 10; i ) {sb.Append(i);sb.Append(' '); }

    • 0
  • raja ram
    Apr, 2014 3

    Both String and String Builder are classes used to handle strings.string is concatenation can performed very efficiently.when concatenation is done it creats a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable". When we make use of the "String Builder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on String Builder object is faster than String operations, as it is done at same location. Usage of String Builder is more efficient in case large amounts of string manipulations.

    • 0
  • Abhay Shanker
    Apr, 2014 2

    System.String is immutable.Immutable means once we create string object we cannot modify Where as System.StringBuilder is mutablePerformance wise string is slow because every time it will create new instance

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS