Reputation: 10441
I would like to do the same thing I do in Java with the final
keyword. I tried to use the const
keyword, but it doesn't work. How can I prevent other classes from inheriting from my class?
Upvotes: 6
Views: 350
Reputation: 4521
In general you should mark your type with sealed keyword in case you want prevent derivation. However is some cases it is not appropriate. For example, you want to allow types from your assembly to derive from your publicly accessible type but prevent third parties from derivation.
Here few tricks which allow you to do this:
Upvotes: 2