24
Reply

Is string mutable or immutable?

Sumit Jolly

Sumit Jolly

Aug 01, 2014
3.3k
0

    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.

    Ankur Jain
    August 18, 2014
    3

    All string objects are immutable in C#.

    manikumar maddu
    August 05, 2014
    2

    strings are always imutable

    Abhishek Kumar
    February 04, 2016
    1

    Immutable

    Joe Wilson
    December 24, 2015
    1

    string iobjects are always immutable

    sajidlkhan lodi
    February 09, 2015
    1

    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);

    Michael O'shea
    June 20, 2015
    0

    Strings are always immutable

    Safayat Zisan
    April 22, 2015
    0

    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.

    Kml Surani
    April 14, 2015
    0

    string objects are always immutable

    sajidlkhan lodi
    February 09, 2015
    0

    string iobjects are always immutable

    sajidlkhan lodi
    February 09, 2015
    0

    string iobjects are always immutable

    sajidlkhan lodi
    February 09, 2015
    0

    string is immutable , can not change value

    Ravi Prajapati
    December 16, 2014
    0

    string is immutable , can not change value

    Ravi Prajapati
    December 16, 2014
    0

    immutable

    Gokul Rathod
    November 25, 2014
    0

    Yes String are immutable.

    Dhanik Sahni
    October 09, 2014
    0

    system.string is immutable

    Munesh Sharma
    October 09, 2014
    0

    Yes String are immutable.

    Akhil Garg
    September 14, 2014
    0

    Immutable,so that they are used for smaller operation

    Sunil Gaded
    August 28, 2014
    0

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

    venky prasad
    August 26, 2014
    0

    Yes string is a immutable

    varunkumar reddy
    August 23, 2014
    0

    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.

    Najna Abdulla
    August 20, 2014
    0

    mutable

    Payal Sharma
    August 11, 2014
    0

    String is Immutable, They cannot be altered

    shashi p
    August 07, 2014
    0

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

    Sumit Jolly
    August 01, 2014
    0