Alex Rivera | Logout

C# - Can publicly inherited methods be hidden (e.g. made private to derived class)

Asked 2008-09-19T23:29:04.357
75

Suppose I have BaseClass with public methods A and B, and I create DerivedClass through inheritance.

e.g.

public DerivedClass : BaseClass {}

Now I want to develop a method C in DerivedClass that uses A and B. Is there a way I can override methods A and B to be private in DerivedClass so that only method C is exposed to someone who wants to use my DerivedClass?

Edit
Report

1 Answer

3

The only way to do this that I know of is to use a Has-A relationship and only implement the functions you want to expose.

answered 2008-09-19T23:31:32.777

Your Answer