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 1102071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:07:38+00:00 2026-05-17T01:07:38+00:00

Given the following code from a Microsoft example: public class EngineMeasurementCollection : Collection<EngineMeasurement> {

  • 0

Given the following code from a Microsoft example:

public class EngineMeasurementCollection : Collection<EngineMeasurement>
{
    public EngineMeasurementCollection()
    {
        Add(new EngineMeasurement { Speed = 1000, Torque = 100, Power = 20 });
        Add(new EngineMeasurement { Speed = 2000, Torque = 160, Power = 60 });
        Add(new EngineMeasurement { Speed = 3000, Torque = 210, Power = 125 });
        Add(new EngineMeasurement { Speed = 4000, Torque = 220, Power = 160 });
        Add(new EngineMeasurement { Speed = 5000, Torque = 215, Power = 205 });
        Add(new EngineMeasurement { Speed = 6000, Torque = 200, Power = 225 });
        Add(new EngineMeasurement { Speed = 7000, Torque = 170, Power = 200 });
    }
}
public class EngineMeasurement
{
    public int Speed { get; set; }
    public int Torque { get; set; }
    public int Power { get; set; }
}

How do I get the minimum/maximum of Speed or Torque or Power. I need this to set the scale on a chart I’m doing (WPF Toolkit Chart to be precise).
I suppose I could have a method inside EngineMeasurementCollection that iterates through each EngineMeasurement and looks at Power (or Speed), but I suspect there is a much easier way? The class Collection does have some sort of Min method, but note, I’m not trying to get the minimum of the collection (I’m not sure what that would mean in this case) but rather, the minimum of a particular property (ex. Speed). I did see the use of Collection.Min with functors. Is there something that could be done there? Or with Linq? I’m interested in all ways.
Thanks,
Dave

Bonus question (perhaps this will be obvious to me with the answer to min/max). What are the options to decide if a value (such as Speed is already in the collection). It’s not clear from this example, but it could be the case that if you already have some data for a given independent variable (time for example), you don’t want any more. So is there something like Collection.Contains(“specify property you are interested in”)?

  • 1 1 Answer
  • 2 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-05-17T01:07:39+00:00Added an answer on May 17, 2026 at 1:07 am
    using System.Linq;
    
    var collection = new EngineMeasurementCollection();
    int maxSpeed = collection.Max(em => em.Speed);
    

    See also:
    LINQ MSDN documentation
    LINQ to Objects 5 Minute Overview

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code (copied from the attoparsec library) what does the inline pragma
Given the following code: final class retVal { int photo_id; } Gson gson =
Given the following code. EventLoopScheduler scheduler = new EventLoopScheduler(ts => new Thread(ts)); BehaviorSubject<int> subject
Given the following code, is there a way I can call class A's version
Given the following code $c= new SoapClient('http://www.webservicex.net/CurrencyConvertor.asmx?WSDL'); $usa = USD; $eng = GBP; doing
I have the following code in project1 that is calling a class from project2.
Given the following code: public enum Pet { Cat, Dog } public interface IOwner
I'm following the Microsoft sample code given for How to create a sink interface
The following code: class Something { public: ~Something() { } }; int main() {
Given the following code from RssToolkit in RssXmlHelper.cs: /// <summary> /// Returns XML of

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.