G
Guest
Hi,
To exclude users based on a criteria, I have created an enum like so:
[FlagsAttribute]
public enum Exclusions:byte
{
None=0,
HaveEmail=1,
IsAdmin=2
};
I would later like to make decisions based on the enum type setting:
Exclusions exclude = Exclusions.HaveEmail & Exclusions.IsAdmin;
switch(exclude)
{
case Exclusions.None:
//dosomething
break;
case Exclusions.HaveEmail:
//dosomething
break;
case Exclusions.IsAdmin:
//dosomething
break;
case (Exclusions.HaveEmail & Exclusions.IsAdmin): //***ERROR***
//dosomething
break;
}
When I try to handle the case where exclude=3 (HaveEmail & IsAdmin), the
compiler generates an error saying the case is already hadled.
Can someone please illuminate why this is not allowed and tell me if it's
possible to do this without puting numeric constants in my case statement?
Thank you very much,
-Keith
To exclude users based on a criteria, I have created an enum like so:
[FlagsAttribute]
public enum Exclusions:byte
{
None=0,
HaveEmail=1,
IsAdmin=2
};
I would later like to make decisions based on the enum type setting:
Exclusions exclude = Exclusions.HaveEmail & Exclusions.IsAdmin;
switch(exclude)
{
case Exclusions.None:
//dosomething
break;
case Exclusions.HaveEmail:
//dosomething
break;
case Exclusions.IsAdmin:
//dosomething
break;
case (Exclusions.HaveEmail & Exclusions.IsAdmin): //***ERROR***
//dosomething
break;
}
When I try to handle the case where exclude=3 (HaveEmail & IsAdmin), the
compiler generates an error saying the case is already hadled.
Can someone please illuminate why this is not allowed and tell me if it's
possible to do this without puting numeric constants in my case statement?
Thank you very much,
-Keith