You cannot influence the value of DateTime.DayOfWeek
, since it is a type of System.DayOfWeek
, which is an enumeration (i.e. the values ββare constant). The definition for System.DayOfWeek
given in the code block below. So, if you want to treat DayOfWeek
as 3
on Monday and Saturday to be the first day of the week, then I have to assume that you need a 1-7 numbering system. In this case, you can do ((int)DateTime.Now.DayOfWeek+1) % 7 + 1
to get the numbers you need. If you do not need this for calculations, it would be better to simply compare the value of DateTime.Now.DayOfWeek
with its enumeration constants (for example, if( DateTime.Now.DayOfWeek == DayOfWeek.Monday ) ...
).
// Summary: // Specifies the day of the week. [Serializable] [ComVisible(true)] public enum DayOfWeek { // Summary: // Indicates Sunday. Sunday = 0, // // Summary: // Indicates Monday. Monday = 1, // // Summary: // Indicates Tuesday. Tuesday = 2, // // Summary: // Indicates Wednesday. Wednesday = 3, // // Summary: // Indicates Thursday. Thursday = 4, // // Summary: // Indicates Friday. Friday = 5, // // Summary: // Indicates Saturday. Saturday = 6, }
source share