Immutable in the context of C# basically means that the value cannot be changed after it’s creation which makes it readonly. Mutable values can be changed at runtime and have no restriction on where they’re changed (so long as they’re accessible)..

Mutable types

Examples: string, int

Immutable types

Examples: const (set in the constructor),  readonly (set only in declaration outside of constructor)

 

Advertisements