C# Programming › Strings in C#

What do you mean by String objects are immutable?

Beginner

Answer

Saying that string objects are immutable means the actual character data stored inside a string object cannot be altered after it has been created in memory. When you assign a new value to a string variable or perform an operation like ToUpper or Replace, C# creates an entirely new string object in memory and simply points your variable to that new object, rather than changing the characters of the original string in place.
string original = "redis";
string upper = original.ToUpper();
// original still equals "redis", upper is a completely separate new string object
Real-world example A caching system safely shares the same string object across multiple threads without any risk of one thread accidentally changing its value, since the immutability of strings guarantees the content can never be modified after creation.

Common follow-ups: How does string immutability relate to thread safety?;Does string interning relate to immutability?