Introduction
This article exlains how to access a private method outside of the class. It is possible using reflection.
Use the following procedure:
Step 1: Create a console application in Visual Studio.
Step 2: Add 2 namespaces
- System
- System.Reflection
Step 3: Now create a class and inside that class create one method that will be private as follows:
Step 4: Now by using the main method call the method as follows:
Complete Code:
Output