Search code examples
c#classmodifier

Decreasing the visibility of base class properties


I had created a base class that has many public properties and were been used perfectly. Now i want to use this class to derive other class , but i do'nt want some of its properties to be exposed outside the derived class that inherits it. Is there any way that the properties of base class that are public cannot be exposed outside its derived class.(The properties that are to be hidden are public because they are used in other classes that inherits it).Any help will be highly appericiated.


Solution

  • You want to make them protected.

    From MSDN:
    A protected member is accessible within its class and by derived class instances.