Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first reason is String is an immutable class.</p> <p>An object qualifies as being called immutable if its value cannot be modified once it has been created. For example, methods that appear to modify a String actually return a new String containing the modification. Developers are modifying strings all the time in their code. This may appear to the developer as mutable - but it is not. What actually happens is your string variable/object has been changed to reference a new string value containing the results of your new string value. For this very reason .NET has the System.Text.StringBuilder class. If you find it necessary to modify the actual contents of a string-like object heavily, such as in a for or foreach loop, use the System.Text.StringBuilder class. </p> <hr> <p>For example:</p> <p>string x= 123 ;</p> <p>if you do x= x + abc what it does is it assigns new memory location for 123 and abc. Then adds the two strings and places the computed results in new memory location and points x to it.</p> <p>if you use System.Text.StringBuilder sb new System.Text.StringBuilder( 123 ); sb.Append( abc ); x sb.ToString();</p> <p>stringbuilder is mutable class. It just adds the string to same memory location. This way string manipulation is faster.</p> <hr> <p>A string is an object of type String whose value is text. Internally, the text is stored as a <strong>readonly collection of Char objects</strong>, each of which represents one Unicode character encoded in UTF-16. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload