Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can a private member Accessable in Derived Class in C#?

Tags:

c#

How Can BaseClass Private function be Accessible into DerivedClass in C#?

like image 355
Swathi Avatar asked Nov 28 '22 11:11

Swathi


1 Answers

Either:

  1. Elevate its access from private to protected
  2. or, add another protected member that accesses it, and use this instead from the derived class
  3. or, use reflection
  4. or, change the code so you don't need to access it

Of the 4, I would chose 1 if it's a private property or method, and 2 if it's a private field. I would add a protected property around the field.

like image 81
Lasse V. Karlsen Avatar answered Dec 18 '22 02:12

Lasse V. Karlsen