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

  • Home
  • SEARCH
  • 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 8258621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:36:21+00:00 2026-06-08T02:36:21+00:00

I need to render a win loss chart based on player performance, I was

  • 0

I need to render a win loss chart based on player performance, I was hoping someone will have experience with similar calculations.

So here is what I have:

public class Player
{
   public virtual bool IsWinner { get; set; }
}

//Sample list
var listOfPlayers = new List<Player>
                                  {
                                      new Player{ IsWinner = true },
                                      new Player{ IsWinner = false },
                                      new Player{ IsWinner = false },
                                      new Player{ IsWinner = true },
                                      new Player{ IsWinner = true },
                                      new Player{ IsWinner = false },
                                      new Player{ IsWinner = true }
                                  };

The players list comes from Database and basically each player in the list belongs to a different match.

So I have this function where I am supplying the list of players and the respective index in the list:

So lets say for example that at index 2 I have one win and 2 losses, because I am rendering a chart I need this function to return a double that will represent the win/loss percentage so it will have (player won 25%of matches 0-3)

public double CalculateWinLossPercentage(List<Player> listOfPlayers,int index)
{
    double winpercentage = null;
    //calculate win percentage base on the total list of players 
    //and the current index in list
    return winpercentage;
}

Thank you in advance for your help.

  • 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-08T02:36:23+00:00Added an answer on June 8, 2026 at 2:36 am
    public double CalculateWinLossPercentage(List<Player> listOfPlayers,int index)
    {
        int count = listOfPlayers.GetRange(0, index + 1).Count(p => p.IsWinner);
        return ((double)count)/(index+1);
    }
    

    This will return the percentage as a double (number between 0 and 1).
    Also, in your example, with index = 2, the correct result would be 33.3%, not 25%.

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

Sidebar

Related Questions

I have some problems with performance in my code… I need to render many-colored
I have a report which is composed of several subreports. I need to render
I have am building a win forms app which will have a text box
I have a table that I need to render some vertical text in one
I have a workflow where I need to render an exception page. But this
I have been brought in on a project where I need to render a
I need to render some JSON based on my model, and I need to
I have the need to render some html text (not an html page with
I have about 5000 markers I need to render on Google Map. I'm currently
We have a grid on our application that we need to render as part

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.