top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Why are strings in C# immutable?

+2 votes
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
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.