Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Mutable and immutable are English words meaning "can change" and "cannot change" respectively. The meaning of the words is the same in the IT context; i.e.</p> <ul> <li>a mutable string can be changed, and</li> <li>an immutable string cannot be changed.</li> </ul> <p>The meanings of these words are the same in C# / .NET as in other programming languages / environments, though (obviously) the names of the types may differ, as may other details.</p> <hr> <p>For the record:</p> <ul> <li><code>String</code> is the standard C# / .Net immutable string type </li> <li><code>StringBuilder</code> is the standard C# / .Net mutable string type </li> </ul> <p>To "effect a change" on a string represented as a C# <code>String</code>, you actually create a new <code>String</code> object. The original <code>String</code> is not changed ... because it is unchangeable.</p> <p>In most cases it is better to use <code>String</code> because it is easier reason about them; e.g. you don't need to consider the possibility that some other thread might "change my string". However, when you need to construct or modify a string using a sequence of operations, it may be more efficient to use a <code>StringBuilder</code>.</p> <hr> <p>And finally, for those people who assert that a <code>StringBuilder</code> is not a string because it is not immutable, the Microsoft <a href="https://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx" rel="noreferrer">documentation</a> describes <code>StringBuilder</code> thus:</p> <blockquote> <p>"Represents a <em>mutable string</em> of characters. This class cannot be inherited."</p> </blockquote>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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