What is reflection?
In simple terms, reflection is a way to get inside of a program, gathering the object information of a program/code and/or invoking these at runtime. So, with the help of reflection, we can analyze and assess our code by writing code in C#. To understand reflection in detail, let's take the example of the class
OddEven
. Here is the partial code of this class:
public class OddEven { public string PrintOddEven(int startNumber, int lastNumber) { return GetOddEvenWithinRange(startNumber, lastNumber); } public string PrintSingleOddEven(int number) => CheckSingleNumberOddEvenPrimeResult(number); private string CheckSingleNumberOddEvenPrimeResult(int number) { var result = string.Empty; result = CheckSingleNumberOddEvenPrimeResult(result, number); return result; } //Rest code is omitted }
After going through the code, we can say this code has a few public methods and private methods. Public methods utilize private...