The C# compiler allows operations between different enum types in another enum type declaration, like this:
public enum VerticalAnchors
{
Top=1,
Mid=2,
C# allows definition of enum values to contain constant value expression, so that an enum value can be a combination of enumerations, e.g. [Flags]
. The compiler evaulates each enum value in the expression as int
(usually), thus you can do bitwise and arithmetic operations on the enum value.
Outside of an enum definition, you must cast the enum to a primitive type before performing an operation on it.