How to query data by using the LINQ to object interface?

Source: Internet
Author: User

My question: http://topic.csdn.net/u/20110430/23/9ccd7f75-4d4b-49b1-9a76-f8c985b607dd.html? 60564

========================================================== ======================================

public static void Linq5()  {         string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };          var shortDigits = digits.Where((digit, index) => digit.Length < index);          Console.WriteLine("Short digits:");          foreach (var d in shortDigits)          {               Console.WriteLine("The word {0} is shorter than its value.", d);           }  }

I believe you are familiar with this LINQ, But I suddenly cannot understand it :)

Here, there is a digit in the where condition. I understand it as a value in digits (I do not know if it is true or not) L

So this index (theoretically the current position)

But I cannot understand where these parameters come from.

========================================================== ==================================

No one cares about me after posting the post. Haha, it's estimated that I 've been playing on May 1, so I 'd better be self-reliant.

After searching for half a day, I couldn't find a result. When the where statement was stopped, I gave a prompt with a glance, and found that the method was heavy-loaded. I checked it to the next one and understood it :)

The basic knowledge is not solid enough. The following is a detailed explanation of Microsoft:

Enumerable. Where <tsource> method (ienumerable <tsource>, func <tsource, int32, Boolean>)

Public static ienumerable <tsource> where <tsource> (

This ienumerable <tsource> source,

Func <tsource, Int, bool> Predicate

)

Type parameter

Tsource

The type of the element in source.

Parameters

Source

Type: system. Collections. Generic. ienumerable <tsource>

Ienumerable <t>.

Predicate

Type: system. func <tsource, int32, Boolean>

A function is used to test whether each source element meets the condition. The second parameter of the function indicates the index of the source element.

Return Value

Type: system. Collections. Generic. ienumerable <tsource>

An ienumerable <t> that contains elements that meet the conditions in the input sequence.


Generation of parameters: "type: system. func <tsource, int32, Boolean> is used to test whether each source element meets the conditions. The second parameter of this function indicates the index of the source element. ", The world is quiet!

Summary: Microsoft wants to reduce programming complexity, but the things to be written have increased :)

I am more and more fond of this fast-moving little fat cat.

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.