Introduction to Reflection API
Introduction
In this tutorial we will learn what is reflection and how to use reflection in .NET.
What is reflection
In computer science, reflection is the ability of a computer program to examine and modify the structure and behavior of the program at runtime. Reflection allows you to obtain information about types defined within assemblies, information about fields, properties and methods.
Reflection in .NET
The classes in the System.Reflection namespace, together with System.Type, enable you to obtain information about loaded assemblies and the types defined within, such as classes, interfaces, and value types. You can also use reflection to create type instances at run time and to invoke them.
The common language runtime loader manages application domains, which constitute defined boundaries around objects that have the same application scope. This management includes loading each assembly into the appropriate application domain and controlling the memory layout of the type hierarchy within each assembly.
Assemblies contain modules, modules contain types and types contain members. Reflection provides objects that encapsulate assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties.