Too long for a comment:
Actually, the [Flags] attribute does not change the semantics of the enumeration at all, it is most often used by the ToString method to retrieve a series of names, not a number, for a combined value.
Let's say your enum was declared as follows (without the Flags attribute):
enum TicketStatus { Created = 1, Transferred = 2, Sold = 4 }
You can still combine different elements and perform any arithmetic that applies to the enumeration of flags:
TicketStatus status = TicketStatus.Created | TicketStatus.Transferred;
However, the following will print 3 :
Console.WriteLine(status);
But if you add the [Flags] attribute, it will print Created, Transferred .
It is also important to note that in TicketStatus.Created | TicketStatus.Transferred TicketStatus.Created | TicketStatus.Transferred you really do a bitwise OR at the base integer value, note how in our example the assigned values ββare uniquely combined:
Created : 0001 Transferred: 0010 Sold: 0100
Therefore, the value 3 can be unambiguously defined as a combination of Created and Transferred . However, if we had this:
enum TicketStatus { Created = 1, // 0001 Transferred = 2, // 0010 Sold = 3, // 0011 }
As can be seen from the binary representations, combining values ββand checking against members is problematic, because the joined members can be ambiguous. for example, what is status here?
status = TicketStatus.Created | TicketStatus.Transferred;
Is it Created, Transferred or is it really Sold ? However, the compiler will not complain if you try to do this, which can lead to complex tracking of errors like yours, where some checks do not work as you expect, so you need to make sure that the definition is normal for bitwise mixing and comparison.
In a related note, since your if really checks to see if it has only Created status, regardless of whether it is merged with other members, the best way to check is (.NET> = 4):
status.HasFlag(TicketStatus.Created)
or (.NET <4):
(status & TicketStatus.Created) != 0
As for why your enum does not work as expected, it is almost certainly because you did not specify an unambiguously bitwise combinable value to your members (usually degree two).