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, ...

Get Learn C# in 7 days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.