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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:11:49+00:00 2026-06-15T19:11:49+00:00

I have an object with two different variables inside. Looks like: ModelB.Text and ModelB.Value

  • 0

I have an object with two different variables inside.

Looks like: ModelB.Text and ModelB.Value and ModelB.Attr

I also have a list of this object and I am loading this List<ModelB> with the data like this:

ModelB.Text = "Car";
ModelB.Value = "345.23";
ModelB.Text = "Car";
ModelB.Value = "343.23";
ModelB.Text = "Car";
ModelB.Value = "323.23";
ModelB.Text = "Toy";
ModelB.Value = "45.23";
ModelB.Text = "Toy";
ModelB.Value = "45.22";
ModelB.Text = "Toy";
ModelB.Value = "45.43";

What I want to do is to find the maximum an minimum valued cars, toys, etc. and check them like ModelB.Attr = "max"; or ModelB.Attr = "min";

So we have to mark the max an min of the each type of object. And yes all the data is string unfortunately and I am parsing it to decimal usually.

  • 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-15T19:11:50+00:00Added an answer on June 15, 2026 at 7:11 pm

    Well, I won’t bother here about parse error, culture and so on : these are business problems, not linq problem.

    I don’t know either what to do if several objects have the same max value : mark them all or not, so I mark the first one. To mark them all, replace First by ForEach

    foreach(var grp in myList.GroupBy(o => o.Text))
        grp.First(g => decimal.parse(g.Value) == grp.Max(o => decimal.Parse(o.Value)).Attr="max";
    

    EDIT : Here is the foreach implementation

    foreach(var grp in myList.GroupBy(o => o.Text))
    {
        string min = grp.Min(o => decimal.Parse(o.Value));
        string max = grp.Max(o => decimal.Parse(o.Value));
        foreach(var obj in grp.Where(o => o.Value == min)
            obj.Attr="min";
        foreach(var obj in grp.Where(o => o.Value == max)
            obj.Attr="max";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two list of different objects : List<Report> List<Newsletter> each having a 'created
Possible Duplicate: Why do this Ruby object have two to_s and inspect methods that
I'm still struggling with this concept. I have two different Person objects, very simply:
If I have two static variables in different compilation units, then their initialization order
Suppose that I have a class like this class Employee: pass I create two
I have an object with an operator defined like this: P& operator +(const P
When I compare two variables typed as object and both contain same value, the
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have an action method that takes in two different objects. I am posting
Possible Duplicate: difference between string object and string literal Let's say I have two

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.