Visual C # core programming-LINQ

Source: Internet
Author: User

1. Lambda expression: input on the left and input on the right Code
In LINQ, lambda expressions have two special signatures. A Lambda expression that returns a Boolean value is called a predicate. Only one parameter of a specific type is accepted, but a different type is returned, which is called projection.
2. Lambda expressions
Lambda expressions encapsulate code, but do not use keywords, normal function signatures, or formal function bodies
Lambda is defined using the lambda operator (=>). The left side is the input, and the right side is the code, similar to the anonymous method.
3. Lambda expression directory tree
In the expression directory tree, the code is data. More precisely, the code in the expression directory tree is filled with Lambda expressions. As data, you can modify or even edit the code at runtime.
The expression directory tree is represented by the expression type, and the expression object is initialized using the lambda expression. binaryexpression encapsulates a Binary Expression, and then Program Extract the topic, left parameter, and right parameter of the expression.
Finally, compile and execute the program.
Expression <func <int, Int, int> product = (x, y) => X * Y;
Binaryexpression body = (binaryexpression) product. Body;
Parameterexpression left = (parameterexpression) body. Left;
Parameterexpression right = (parameterexpression) body. Right;
Console. writeline ("{0} \ nleft: {1} Right: {2}", body, left, right );
VaR Lambda = product. Compile ();
Console. writeline (lambda (3, 2 ));
4. C # language query syntax

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.