What arithmetic operations are supported in C # enumerations? Surprisingly, I could not find it using google, nor with wikipedia and stackoverflow.
Is it possible to add two enumeration values without any actors ? Add arbitrary constant to value or subtract it? Or does enum guarantee that a value of this type is always one of the defined enumeration values โโor their bitmasks?
class ... {...
enum WeekDays : byte { Sun = 1, Mon = 2, Tue = 3, Sat = 7 };
public static bool IsWeekend (WeekDays _d) {
}
I know about bitwise operations, it seems reasonable to support them to represent flags.
Wikipedia tells us that my example also allows _d - 1or WeekDays.Tue - WeekDays.Mon, which may be useful for strictly ordered consecutive enumerations, but I cannot find a standard link, could you point me to?
source
share