tags:

views:

227

answers:

3

I would like to do the same thing I do in Java with the final keyword. I tryed to use const keyword... but it doesn't work. How can I prevent other class to inherit from my class?

+18  A: 

The keyword you are searching is "sealed".

MSDN

Daok
Or, more specifically, "sealed". :)
Vilx-
edited to fix :)
annakata
Yeah, thanks you are right, I added the link to it. It's sealed (to seal!). I have to agree that I do not use this keyword a lot.
Daok
+5  A: 

"NonInheritable" for VB.NET

MSDN

MOZILLA
+1  A: 

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:

Dzmitry Huba