enums - Possibility of assumption in C# -
can make assumptions on casted int value of system enums in c#?
for example:
//dayofweek (int)dayofweek.monday == 1, (int)dayofweek.tuesday == 2, (int)dayofweek.wednesday == 3, (int)dayofweek.thursday == 4, (int)dayofweek.friday == 5, (int)dayofweek.saturday == 6, (int)dayofweek.sunday == 0
the logic of code depends on it. however, don't feel writing own mapping, because it... wrong solution.
edit here comes culture thing well. iso standard - monday 1st day. in usa - sunday 1st day.
yes, can rely on it, insofar documented that:
the dayofweek enumeration represents day of week in calendars have 7 days per week. value of constants in enumeration ranges dayofweek.sunday dayofweek.saturday. if cast integer, value ranges 0 (which indicates dayofweek.sunday) 6 (which indicates dayofweek.saturday).
of course, while unlikely so, microsoft free change in future releases.
Comments
Post a Comment