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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:14:11+00:00 2026-05-15T10:14:11+00:00

I am not sure if CopyMost is the correct term to use here, but

  • 0

I am not sure if CopyMost is the correct term to use here, but it’s the term my client used (“CopyMost Data Protocol”). Sounds like he wants the mode? I have a set of data:

Increment    Value
.02            1
.04            1
.06            1
.08            2
.10            2

I need to return which Value occurs the most “CopyMost”. In this case, the value is 1. Right now I had planned on writing an Extension Method for IEnumerable to do this for integer values. Is there something built into Linq that already does this easily? Or is it best for me to write an extension method that would look something like this

records.CopyMost(x => x.Value);

EDIT

Looks like I am looking for the modal average. I’ve provided an updated answer that allows for a tiebreaker condition. It’s meant to be used like this, and is generic.

records.CopyMost(x => x.Value, x => x == 0);

In this case x.Value would be an int, and if the the count of 0s was the same as the counts of 1s and 3s, it would tiebreak on 0.

  • 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-05-15T10:14:11+00:00Added an answer on May 15, 2026 at 10:14 am

    Well, here’s one option:

    var query = (from item in data
                 group 1 by item.Value into g
                 orderby g.Count() descending
                 select g.Key).First();
    

    Basically we’re using GroupBy to group by the value – but all we’re interested in for each group is the size of the group and the key (which is the original value). We sort the groups by size, and take the first element (the one with the most elements).

    Does that help?

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

Sidebar

Related Questions

Not sure if this is the correct Stack Exchange website but here goes.. A
Not sure if my title is correct. Forgot what it is code. But here
Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure if im just being stupid or something but here goes i work
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid
Not sure what's going on here, but in my Rails 3 application, I type
not sure what i'm missing, but here ti go's: i have a floating left
Not sure what I'm doing wrong, but here is the code 1: var currDoc:NotesDocument
Not sure if this belongs here because its not technically a 'programming' question, but
Not sure what the problem is here, but I keep getting the result 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.