Calling a private base method from a derived class in C #

How a derived class can call a method from a base class.
Other classes should not have access, on the other hand.

My situation:
I have a base class in which I wrote a private method for registering some values.

private void register(string param1, int param2){//...} 

I did this to allow subclasses to register different things.
The problem is that the derived class cannot access private methods or fields of the base class.
This makes sense to me, since private funds are PRIVATE. I do not want the method to be publicly available, because other classes could not call this method.
Can someone provide a solution or lead me to a better design?

+6
source share
1 answer

When you declare something personal, only the class available to it can get access. Not even derived classes

You need protected

When something is declared protected , any derived class can access it while remaining hidden from other unrelated classes.

+15
source

Source: https://habr.com/ru/post/977878/


All Articles