Sudhanshu Jain Sudhanshu Jain - 1 month ago 7
C# Question

If we inherit a class do the private variables also get inherited?

If we inherit a class do the private variables also get inherited?

I know that "Yes, the variables are inherited but cannot be accessed directly by the class interface."

What I want to know is how can we access the private variables/methods from the child class

What I am trying to say is that private members are also inherited.But how to access the same without making them protected.

Answer

What I want to know is how can we access the private variables/methods from the child class ......... But how to access the same without making them protected.

You might want to try using reflection:
Here is a similar question / answer that explains how this can be done.