Reputation: 135
I am starting a class for Events. Currently there are two enums.
[Flag]
public enum Status
{
statusA,
statusB,
statusC,
statusD,
}
[Flag]
public enum StatusType{
Request,
Success,
Fail,
Start,
End
}
I would like to be able to raise the event, Action RequestingStatusA (Status.StatusA & StatusType.Request) for example. This of course, gives errors. Is there anyway to combine them on the fly but make it as a signature such that the event handler would recognise it.
Should I be even doing it this way even? Thanks in advance.
Upvotes: 2
Views: 1410
Reputation:
No. Not only that, but you will have collisions if you try to map the non-transformed bit values - so don't blinding consider casting to int
:)
Why not create (and pass) a new type that wraps values of both enum types?
struct RequestStatus {
// implement as desired
public StatusType Type { get; set; }
public Status Status { get; set; }
}
Action RequestingStatusA (RequestStatus status) {
..
}
Upvotes: 3