Is it correct that it is not possible to change the value of an immutable object?
I have two scenarios regarding readonly that I want to understand:
What if I have a collection and mark it as
readonly, like the following. Can I still call_items.Add?private readonly ICollection<MyItem> _items;And also for the following variable, if later on I call
_metadata.Changewhich will change the internal values of a couple member variable in theMetadatainstance. Is_metadatastill immutable?private readonly Metadata _metadata;
For both variables above, I totally understand that I can't directly assign new values to them outside of initializer and constructors.