I'm trying to map a certain wind speed (measured in meters per second) to the appropriate label, taken from http://www.windfinder.com/wind/windspeed.htm. For this, I'd like to use switch statements
, however I'm not sure how to do this in C#
.
In ActionScript
, it was possible using switch blocks, I've also seen it in Clang
.
// ActionScript 3
switch(true) {
case: mps >= 0 && <= 0.2
return WindSpeedLabel.Calm; break;
...
case else:
WindSpeedLabel.ShitHittingTheFan;
}
// Clang
switch(mps) {
case 0 ... 0.2:
return WindSpeedLabel.Calm;
...
I'm aware it's possible using if/else statements
, however with about 13 different ranges, I would appreciate a more readable solution.