We know the concept of immutability but need to know few immutable types other than
Are there more?
Some examples from mscorlib:
decimal
(U)IntPtr
DateTime
, DateTimeOffset
, TimeSpan
KeyValuePair<,>
- as an opposite, DictionaryEntry
is not immutableTuple<...>
(Multicast)Delegate
- similarly to strings, always a new instance is returned when it is changed.Guid
Version
Interestingly, string
is actually not really immutable; however, we can treat it as a "practically immutable" type, meaning, that the content of a string instance cannot be changed by the public ways (at least, in a safe context). But it has for example a wstrcpy
internal method, which is used by the StringBuilder
class to manipulate a string instance.