Question: I wonder if there is a way to limit who can inherit from a class.

* `internal`: doesn't allow class to be inherited outside the assembly
* `sealed`: class cannot be inherited

Is there a keyword or way to allow only certain classes (let's say from it's own namespace only) to inherit that class?

Also, I do not want this special class to be generic.
My concern isn't security but the design in general.

Example of what I want:

* Class A.
* Class B inherits from A
* Class C cannot inherit from A

Answer: 
> 
> Is there a way to allow only certain classes to inherit that class?
> 
> 
> 

Yes. If the inheriting code is *partially trusted* then you can put an *inheritance demand* on the base class and the runtime will not allow the inheriting class to load if it does not meet the conditions of the demand:

<https://msdn.microsoft.com/en-us/library/x4yx82e6(v=vs.100).aspx>

Of course, *full trust means full trust*. Fully trusted code can inherit whatever it wants.

I suspect that you're trying to impose restrictions that you really should not be trying to impose. Can you describe why you're trying to do this difficult thing? There's probably a better way to do what you want.

UPDATE:

> 
> I'm trying to limit inheritance within my classes in the same assembly. 
> 
> 
> 

Then you probably should have said that in the first place.

Make all the constructors of the class internal. In order to inherit from a class, it must have an accessible constructor. If you make all the constructors internal then only classes in that assembly can inherit from the base class.
As far as I know, using `internal` is the only way to control who can inherit a class. If the inheritors must be in a different assembly, you can let classes from another assembly see internals of your assembly using [`InternalsVisibleTo`](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx) attribute (the target assembly must be signed in order for this to work with signed assemblies).