In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created.
The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory. Ex: String.
Making an object immutable is usually inappropriate if the object contains a large amount of changeable data.
So, For this reason .NET has the System.Text.StringBuilder class which is Mutable and appropriate for large amount of changeable data.
Asked In: Many Interviews |