Private, Protected, Internal Inheritance

Topics: C# Language Design
Aug 14, 2014 at 8:40 AM
To improve encapsulation abilities of C# we need Inheritance access modifier
public class Figure
{
    public void Show( ){...}
}

public class ConcreteType : private Figure
{
    public void new Show( )
    {  
        SomeLogic
        base.Show( );
        SomeLogic
    }
}
...
var ct = new ConcreteType();
var f = new Figure();

ct is Figure == false
(Figure)ct //Cast Exception
So no one can cast ConcreteType to Figure and no one can call Figure.Show on ct object
Aug 14, 2014 at 11:46 AM
This sounds like you should use composition, not inheritance.