top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why are strings in C# immutable?

+2 votes
248 views
Why are strings in C# immutable?
posted Dec 1, 2014 by Roshan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

• When string values changes it means string is immutable, in this whenever we assign new value to string it occupies new memory reference for its new value by creating new string instance.
• String is declared by using String Keyword.
• Always use mutable string defined in System.Text.StringBuilder whenever its values will change.
• Inefficient use of memory and garbage collection resulted by Immutable string.

answer Dec 1, 2014 by Manikandan J
...