Solved

Best way to graphically show a numeric range - Switch Statement?

Posted on 2011-02-15
3
435 Views
Last Modified: 2012-05-11
I'm doing some file anlytics and want to show a green check image for 100%, an orange one for 90 to 100%, then a red one for less than 90%.

Does anyone have a c# example of this?  I started using a switch statement, but it doesn't seem to allow me to enter ranges.  
0
Comment
Question by:JT_SIRO
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
silemone earned 125 total points
ID: 34899618
why not use a simple if/else contruct

if (x > 10 && x < 90)
0
 
LVL 7

Assisted Solution

by:dimaj
dimaj earned 125 total points
ID: 34899888
switch (myNumber) {
  case myNumber >= 0 && myNumber < 10:
     // display color 1
  case myNumber >= 10 && myNumber < 20:
     // display color 2
  case myNumber >= 20 && myNumber < 30:
     // display color 3
  case myNumber >= 30 && myNumber < 40:
     // display color 4
  case myNumber >= 40 && myNumber < 50:
     // display color 5
  case myNumber >= 50 && myNumber < 60:
     // display color 6
  case myNumber >= 60 && myNumber < 70:
     // display color 7
  case myNumber >= 70 && myNumber < 80:
     // display color 8
  case myNumber >= 80 && myNumber < 90:
     // display color 9
  case myNumber >= 90 && myNumber < 100:
     // display color 10
  case default:
    // there was an error
}
0
 
LVL 7

Expert Comment

by:dimaj
ID: 34899917
if those cases don't work, you can always resort to using IFs

if (range 1) {
  color 1
}
else if (range 2) {
  color 2
}
else if (range n) {
 color n
}
else {
 // error
}
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question