C # Learning (6)--linq Learning

Source: Internet
Author: User

Language-Integrated Query (LINQ) is the name of a set of technologies that are built on the direct integration of query functionality into the C # language (as well as Visual basic and any other possible. NET language). with LINQ, the query is now a high-level language construct, just like classes, methods, events, and so on.

For developers writing queries, the most obvious "language integration" part of LINQ is the query expression.query syntax introduced in C # 3.0. " The query expression is written using the declarative query syntax introduced in C # 3.0.   You use the same basic query expression pattern to query and transform data in SQL databases, ADO datasets, XML documents and streams, and. NET collections. While LINQ and SQL statements are very similar so they are well understood.

The following example shows the full query operation. complete operations include creating a data source, defining a query expression, and executing a query in a foreach statement.

classlinqqueryexpressions{Static voidMain () {//specify the data source.        int[] scores =New int[] { the, the,Bayi, - }; //Define the query expression.ienumerable<int> scorequery = fromScoreinchscoreswhereScore > the            Selectscore; //Execute the query.        foreach(intIinchscorequery) {Console.Write (i+" "); }                }}

OUTPUT:97 92 81

C # Learning (6)--linq Learning

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.