Reflection:

  • Reflection provides the ability to examine and manipulate the metadata and behavior of types at runtime.
  • It allows you to dynamically create instances, invoke methods, access properties, and perform other operations based on type information.
  • Reflection is commonly used in frameworks, libraries, and tools that need to work with unknown or dynamically loaded types.

Example:

Type type = typeof(MyClass);

MethodInfo method = type.GetMethod(“MyMethod”);

object instance = Activator.CreateInstance(type);

method.Invoke(instance, null);