user image

Preeti Tripathi

Job Interview Skills
English
2 years ago

Question 169. How Can You Access A Private Method Of A Class?

user image

Abhishek Mishra

2 years ago

Use .Net Reflection. Using reflection we can invoke private methods too. Example: Car car = new Car(); Type type = car.GetType(); MethodInfo methodInfo = type.GetMethod("ShiftGearUp", BindingFlags.NonPublic | BindingFlags.Instance); methodInfo.Invoke(car, null); Pre: Create a class Car with private method "ShiftGearUp"

Recent Doubts

Close [x]