My goal is to make sure that in most scenarios objects are used via a "read-only interface" that is a subset of the full interface.
const
object.So, how can I achieve my goal in C#?
How about if you placed your write operations in an interface and then implement in explicitly on the abstract base class? It would not be a 100% perfect solution (you could still cast the object to the modification interface), but for most part it would prevent anyone from accidentally calling the modifying methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With