A very useful feature in. NET--reflection

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.