24
Reply

Is string mutable or immutable?

Sumit Jolly

Sumit Jolly

10y
3.3k
0
Reply

    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.

    All string objects are immutable in C#.

    strings are always imutable

    Immutable

    string iobjects are always immutable

    String objects are NOT ALWAYS immutable. Ignore all posts in this thread that spread this misconception. Below for example I show an example where I take "thequickbrownfox" and change each character in turn into "THEQUICKBROWNFOX" The original string is mutable in this example. String s = "thequickbrownfox"; Console.WriteLine(s); unsafe { fixed (char* ca = s) for (char* c = ca; *c != 0; c++) *c = char.ToUpper(*c); } Console.WriteLine(s);

    Strings are always immutable

    Immutable string can’t be alter, once we have assign a value to immutable object state can’t be changedWe can assign multiple values to mutable string and object state can be altered.

    string objects are always immutable

    string iobjects are always immutable

    string iobjects are always immutable

    string is immutable , can not change value

    string is immutable , can not change value

    immutable

    Yes String are immutable.

    system.string is immutable

    Yes String are immutable.

    Immutable,so that they are used for smaller operation

    All strings are immutable.because if you try to insert a value more than once it will replace previous value.String Builders are mutable.

    Yes string is a immutable

    Immutable means string values cannot be changed once they have been created. Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and extraneous garbage collection. The mutable System.Text.StringBuilder class should be used when string values will change.

    mutable

    String is Immutable, They cannot be altered

    mutable means "changeable" and immutable is acronym of that.strings are immutable.