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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:05:54+00:00 2026-06-03T18:05:54+00:00

My program cannot determine whether to execute Math.Round as a decimal or a double

  • 0

My program cannot determine whether to execute Math.Round as a decimal or a double, but I have no idea how to fix this… Here is my code, though the second to last line is what I am concerned with.

 ArrayList topp1 = new ArrayList();
 int toppcount = 0;
 foreach (Control cb in GroupBoxH1T.Controls)
 {
     CheckBox cb1 = cb as CheckBox;
     if (cb1.Checked == true)
     {
          toppcount++;
          topp1.Add(cb1.Text);
     }
  }

  if (cbhwchoice.Checked == false)
  {
      ArrayList topp2 = new ArrayList();
      foreach (Control cb in GroupBoxH2T.Controls)
      {
          CheckBox cb1 = cb as CheckBox;
          if (cb1.Checked == true)
          {
              toppcount++;
              topp2.Add(cb1.Text);
          }
      }

      toppcount = Math.Round((toppcount/2,MidpointRounding.AwayFromZero);
  }
  • 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-03T18:06:10+00:00Added an answer on June 3, 2026 at 6:06 pm

    Math.Round expects a floating point or decimal number because calling it on an integer would have no effect. If you want to call it, pass in a value of that type. To do so, you can simply cast the numerator and denominator to the desired type. For Example:

    decimal value = Convert.ToDecimal(toppcount) / 2.0M;
    toppcount = Math.Round(value, MidpointRounding.AwayFromZero);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a memory leak in my C# program and cannot determine who is
I've been thinking about a program logic, but I cannot draw a conclusion to
I have a Delphi program and I'm looking how this program could print its
How ASP.NET compiles its assemblies generally confuses me. It seems that I cannot program
I cannot figure out why the following simple program doesn't (create) and then write
This program I use has it's own variables to set when you run it,
I want to make a program which will determine the Rank of a given
I have a program that stores user projects as databases. Naturally, the program should
As soon as I open the VS cmd prompt it says ERROR: Cannot determine
Ok the only problem with this program is at the end where I try

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.