Coming from a C++ background and trying to learn C#, one of the most frustrating language omissions that I've come across is an equivalent to the const
keyword.
So, I have been attempting to settle on a pattern that I can use to achieve const correctness in C#.
This answer has an interesting suggestion: create a read only interface for all of your types. But as Matt Cruikshank pointed out in the comments, this becomes problematic if your class has collections or other rich types. Particularly if you do not have control over the type, and can't make it implement a read-only interface.
Do any patterns or solutions exist that can handle rich types and collections, or are we forced in C# to simply make copies? Is it better to just give up on const correctness in C# altogether?