C # 3.0 Language new features (language Specification): 8 expression tree

Source: Internet
Author: User
Specification

Original: "C # Version 3.0 Specification", Microsoft
Translation: Lover_p
The expression tree allows lambda expressions to be represented as data structures rather than executable code. A lambda expression that can be converted to a delegate type D can also be converted to an expression tree of type system.query.expression<d>. Converting a lambda expression to a delegate type causes the executable code to be generated and referenced by the delegate, and converting it to an expression tree type causes the code that created the expression tree instance to be emitted (Emit). An expression tree is an efficient, in-memory (in-memory) data representation of a lambda expression, and makes the structure of the expression transparent and explicit.

The following example displays a lambda expression for executable code and expression tree respectively. Because of the existence to the Func<int, the int> conversion, therefore exists to the Expression<func<int, int>> conversion.

Func<int, int> f = x => x + 1; Code

Expression<func<int, int>> e = x => x + 1; Data

After these assignments are complete, the delegate F identifies a method that returns X + 1, whereas the expression tree E represents a data structure that describes the expression x + 1.

Attention

The structure of the expression tree will be converted to a separate specification. This specification does not apply in the PDC 2005 Technical Preview.



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.