Reflection & Metadata Manipulation
🪞 2. Reflection and Runtime Type Inspection
Reflection lets you inspect and manipulate types at runtime, useful for frameworks, serializers, and ORM tools.
Type type = typeof(Person);
var properties = type.GetProperties();
foreach (var prop in properties)
{
Console.WriteLine($"{prop.Name}: {prop.PropertyType}");
}
🔹 Invoking Methods Dynamically
MethodInfo method = type.GetMethod("Speak");
method.Invoke(new Person(), null);