Using a linq query/method chainging I wish to select just the first 2 Point objects in a List ordered by Point.X. How can I?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Breaking it down:
OrderBy()takes a lambda expression which selects the key by which to order. In this case, we want to return the.Xproperty on the object. Another example is if we had aPersonobject and wanted to sort by.FirstName, the key selector would be(item => item.FirstName).Take()truncates the enumeration to the specified number.