Reflection

In C#, reflection is used to obtain metadata on types at runtime. In other words, it allows developers to retrieve data on the loaded assemblies and the types within them.

It’s implemented using a two-step process. First, you get the type object. Second, you use the type to browse members, such as methods and properties.

// Using GetType to obtain type information:
int i = 42;
Type type = i.GetType();
Console.WriteLine(type);

Last updated