C#: Can a Child class restrict access to Parent class methods?

c#, inheritance

Solution

You should have a base abstract class to hold the things in common of both classes, and then let the other two classes inherit from it and add methods and properties, etc.

abstract class MyBaseClass
{
    public int SharedProperty { get; set; }

    public void SharedMethod()
    {
    }
}

class MyClass1 : MyBaseClass
{
    public void Method1()
    {
    }
}

class MyClass2 : MyBaseClass
{
    public void Method2()
    {
    }
}

`MyClass1` has: `SharedProperty`, `SharedMethod`, and `Method1`.

`MyClass2` has: `SharedProperty`, `SharedMethod`, and `Method2`.

Problem

I have a need for two slightly different classes, that have the same members, but one of the classes needs to have less interaction possibilities by the user. I am hoping to inherit the second class from the first. Is there a way to restrict access to parent methods from the child class, so that if somebody creates a child object, they will not be able to access certain parent class methods (which are public in the parent class)?

Original source