C #3.0 sharp experience (2) LINQ

Source: Internet
Author: User
Introduction to LINQ
1. Net Language Integrated Query (LINQ): a general solution is used to address access and integration of various information sources, instead of a proprietary solution specific to relational databases or XML.
2. In LINQ, the query becomes Programming Language This allows the query expression to get a good syntax check during compilation, rich metadata, and SMART awareness of the benefits of other strong languages.

Syntax format:

Class Program
{
Static   Void Main ( String [] ARGs)
{
String [] Names =   { " Burke " , " Connor " , " Frank " , " Everett " , " Albert " , " Geroge " , " Harris " , " David " } ;
Ienumerable < String > Query = From S In Names
Where S. Length =   5
Orderby s
Select S. toupper ();
Foreach ( String Item In Query)
{
Console. writeline (item );
}
Console. Readline ();

}
}

Above:
Ienumerable < String > Query = From S In Names
Where S. Length =   5
Orderby s
Select S. toupper ();
Equivalent
Ienumerable < String > Query = From S In Names
Where (S => S. Length =   5)
Orderby (S => S)
Select (S => S. toupper ());

Equivalent to the following Commission: Func < String , Bool > Filter =   Delegate ( String S) {
ReturnS. Length= 5;}
Func < String , String > Extract =   Delegate ( String S) {
ReturnS ;}
Func < String , String > Project =   Delegate ( String S) {
ReturnS. toupper ();} ;
Ienumerable < String > Query = Names. Where (filter)
. Orderby (extract)
. Select (project );

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.