What is reflection, generics, delegation, and generics?

Source: Internet
Author: User

When I learned these things, I checked them online for a long time. I felt very professional. It was hard for beginners to understand when to use them. It was also difficult to find a simple introduction. I would like to explain it a little bit:
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------
Reflection: Reflection
1. When the base class calls the derived class, use
2. At runtime, it is determined which class to call
3. obtain information about the modular assembly class constructor attribute method and the instantiation class at runtime,
Call constructors, attributes, methods, events, delegates, and so on ...... After dynamic instantiation of types, you can also use reflection to perform operations on them.
4. If you can determine the class you want to call when writing code, you can call it directly.
However, in many cases (maybe for universality), the type to be called must be determined at runtime, so reflection is necessary to obtain information about the type.

In simple terms, it is something that can be done at runtime with a string. It is actually a universal factory built in. net framework.
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------
Generic:
1. Reduce packing and unpacking; high performance; 2. type security; 3. Improved work efficiency
But who knows how to briefly describe him?
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------
Cache-Cache dependency:
1. When the user visits the webpage again, the formatted HTML will be directly displayed. Fast
2. dependent on the data source. cache is regenerated when the data source changes. The data source can be a file or database.

Generally, it is used to optimize websites.
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------------------
Delegate:
1. Delegation is a type that can be affirmed. methods are considered as delegated instances. Therefore, methods can be transferred!
(Passing methods as parameters) can avoid using If-Else (Switch) statements in a large number in the program, and make the program more scalable.
2. You can bind multiple methods to the variable (+ = or-=) of the same delegate using delegation)
3. Whether an event is declared as public or not, it is actually private. private variables cannot directly use equal signs (=). That is to say, it is not easy to bind an event with a number = to a function.
All the encapsulated + =,-= actually + = "corresponds to the add_XXX () method, and"-= "corresponds to the remove_XXX () method.
4. the return value is void.
If the return value is defined, the methods of multiple subscriber will return a value to the publisher. The result is that the method value returned later overwrites the previous return value,
Therefore, you can only obtain the return value of the last method call.
5. delegate is equivalent to a pointer in C. It is type-safe
A delegate is equivalent to a boss. The boss can control many employees to do things at will, and a delegate can also bind N multiple functions.

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.