Solved

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

Posted on 2011-02-15
3
433 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now