C # reflection (system. Reflection)

Source: Internet
Author: User
C # system. Reflection reflection Reflection Overview

Reflection appdomain Of Program Set

Reflection of a single assembly

Obtain type information using reflection

Set reflection type members

Create a type of instance through reflection

Reflection interface

Reflection Performance

Reflection Overview

Reflection definition: the ability to review metadata and collect information about its type. Metadata (the most basic data unit after compilation) is a lot of tables. When compiling an assembly or module, the compiler creates a class definition table and a field definition table, and a method definition table ,. The system. Reflection namespace contains several classes that allow you to reflect (PARSE) the metadata tables Code

Reflection-related namespaces (we access reflection information through these namespaces ):

System. reflection. memberinfo

System. reflection. eventinfo

System. reflection. fieldinfo

System. reflection. methodbase

System. reflection. constructorinfo

System. reflection. methodinfo

System. reflection. propertyinfo

System. Type

System. reflection. Assembly

Layered reflection model:


Note: There is a one-to-many relationship between layers.

Function of reflection:

1. You can use reflection to dynamically create instances of the type, bind the type to an existing object, or Retrieving types in objects

2. An application needs to load a specific type from a specific set of programs at runtime, so that reflection can be used for a task.

3. Reflection main applications and class libraries. These class libraries need to know a type definition to provide more functions.

Application highlights:

1. In real applications, few applications need to use the reflection type.

2. Dynamic reflection binding sacrifices performance.

3. Some metadata information cannot be obtained through reflection.

4. Some reflection types are specifically for those CLR Development compiler development and use, so you need to realize that not all reflection types are suitable for everyone.



Reflection appdomain Assembly

When you need to reflect the appdomain For example:
Static Void Main

{

// Use getassemblies Call all Assembly of appdomain

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.