Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:46:26+00:00 2026-06-05T10:46:26+00:00

Does anybody know how to access a specific field from List<>? I cant figure

  • 0

Does anybody know how to access a specific field from List<>? I cant figure out howto access a specific field in newList object.

  List<Liner> LX = new List<Liner>();

  public class Liner
  {
      public double Temperature { get; set; }
      public double Moisture { get; set; }
  }

newList = LX.OrderBy(x => x.Temperature).ToList();

var lstMXLast = newList.GetRange(8755, 5);  // I need only 5 specific Moisture records in this case. 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:46:28+00:00Added an answer on June 5, 2026 at 10:46 am

    GetRange returns a copy of the list with the given range. So your list needs at least 8760 items. To select only the Moisture property of your objects, you can use LINQ’s Select:

    var lstMoistures = newList.GetRange(8755, 5).Select(l => l.Moisture).ToList();
    

    Note: you need the ToList at the end only if you want to persist the query. Your ToList at the end of the OrderBy query is useless because you want to chain another query. I would materialze LINQ queries only as late as possible.

    You could also use LINQ for the whole thing:

    var lstMoistures = newList.Skip(8755).Take(5).Select(l => l.Moisture).ToList();
    

    Assuming that you originally wanted to select the 5 liners with the highest temperature, this should give you the correct result:

    var lstMoistures = LX.OrderByDescending(x => x.Temperature).Take(5).Select(l => l.Moisture).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know how to access the Xbox Live Avatar from within an XNA
Does anybody know how to read the user\group access permissions from an MSMQ private
Does anybody know if you can access the SaevFileDialog control that's used by the
does anybody know how i can access a custom cell within the - (void)tableView:commitEditingStyle:forRowAtIndexPath:.
Does anybody know of or have a detailed list of how the BCL in
Does anybody know, how to get a list of leaf nodes in Prolog? Let's
Does anybody know if it is possible to access and manipulate an element in
does anybody know of a secure 'read-once' local file access system? Or how one
Does anybody know a way how to get access to the Flattr users Gravatar
Does anybody know how to get access to the template's body inside the page?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.