0

I have a simple enum with a few values

Enum Status{
Available, 
Taken,
Sold//and many more
}

I want to check whether the status is somewhere in between the possible values(assuming the values are written in such an order that the lowest are the beginning of a process, and the last ones are the final steps of the process)

Something like

Status s1;//Some value
if(s1<5 && s1>3)
//The value is one of the enum values in those range
//(for example the job has already been accepted, but has still not been
//shipped)

Is it possible?

Thanks.

master2080
  • 366
  • 3
  • 15

1 Answers1

2

You can assign integer values to your enum and then check.

enum Status
{
    Available = 1, 
    Taken = 2,
    Sold = 3
    //and many more
}

Status s1; // any value
if ((int)s1 <= 5 && (int)s1 >= 3)
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Ian H.
  • 3,840
  • 4
  • 30
  • 60