Solved

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

Posted on 2011-02-15
3
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

622 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