What is the tilde (~) in the enum definition?

~ is the unary one's complement operator -- it flips the bits of its operand.

~0 = 0xFFFFFFFF = -1

in two's complement arithmetic, ~x == -x-1

the ~ operator can be found in pretty much any language that borrowed syntax from C, including Objective-C/C++/C#/Java/Javascript.


I'd think that:

[Flags]
public enum PurchaseMethod
{
    None = 0,
    Cash = 1,
    Check = 2,
    CreditCard = 4,
    All = Cash | Check | CreditCard
 }

Would be a bit more clear.