akshaykumar6 akshaykumar6 - 1 year ago 190
C# Question

How to get the integer value of day of week

How do I get the day of a week in integer format? I know ToString will return only a string.

DateTime ClockInfoFromSystem = DateTime.Now;
int day1;
string day2;
day1= ClockInfoFromSystem.DayOfWeek.ToString(); /// it is not working
day2= ClockInfoFromSystem.DayOfWeek.ToString(); /// it gives me string

Joe Joe
Answer Source


day1 = (int)ClockInfoFromSystem.DayOfWeek;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download