We know the concept of immutability but need to know few immutable types other than
Are there more?
TimeSpan
, or modern type family Tuple
. Tuple
is immutable cause it implemented to support functional languages (F# f.e.) in .NET.
Of course you can make your own classes and structures mutable or immutable, as you wish. Immutable types (aka value objects) are useful in multithreading programming, functional programming, to clear a code.
To make a class or struct immutable just remove all public/protected/internal setters; and better declare all fields with readonly
keyword.