Level 7 — Metadata
Reflection
Original notes by SunDiaL · View English source
Reflection is the ability of a program to inspect itself while running. It lets you look at:
- All classes, functions, properties in an assembly
- The types of variables at runtime
- What attributes are applied
Type type = typeof(MyClass);
var methods = type.GetMethods();
var attrs = type.GetCustomAttributes(false);
In short: Reflection is how you read the metadata — Attributes are just one kind of metadata.