Reflection is a very useful feature in. Net.
What is reflection
It can be summed up in one sentence: based on the assembly and metadata , you can dynamically create an instance of a type, invoke a method, and access an object member's ability.
Why do you use reflection
You have to use reflection when you cannot determine the object to invoke at compile time.
Reflection of the application scenario
The most common application scenarios are:
1, based on the Factory mode implementation of database switching.
2,orm framework, because it faces a generic model, and all properties or methods are generated dynamically.
3, the plugin-based system, in the case of completely unaware of what the external plug-in is, is bound to not be determined at compile time, so it will be loaded with reflection.
Assembly
Because reflection is based on assemblies and metadata, it is necessary to explain what the assembly is and what the metadata is.
Assemblies: Assemblies are collections of all types that are compiled to generate PE files (such as executable. exe and class library file. dll).
Metadata: Metadata is a part of the assembly that contains information such as name, version, language culture, and public key token.