
Signature
Happy coding!
Morten Wennevik [C# MVP]
Thanks Morten.
I got it to work by casting DayOfWeek to (int), adding 6 to it, modulo
7 the sum, and recasting it to Day.
It works fine, but is it good practice to make assumptions about the
underlying value of eumerated types? If Microsoft were to change the
integer values, my program would break.
These two properties are to get/set the day that is used as the first
day of the week in the current culture (eg Saturday is the first day of
the week for Saudi Arabia). I wonder if it is a simple case of the
Windows.Forms department in Microsoft not talking to the Globalization
department. There should be just one type for the two properties.
Morten Wennevik - 23 Aug 2005 15:17 GMT
I don't think either of the enumerations will ever change as it most likely will break a great many applications, but if you want to be sure any future changes won't break your code, you could always use the string value of the DayOfWeek enumeration and parse that with the Day enumeration.
DayOfWeek d1 = DayOfWeek.Sunday;
Day d2 = (Day)Enum.Parse(typeof(Day), d1.ToString());
> Thanks Morten.
>
[quoted text clipped - 10 lines]
> Windows.Forms department in Microsoft not talking to the Globalization
> department. There should be just one type for the two properties.

Signature
Happy coding!
Morten Wennevik [C# MVP]