Как я могу сравнить текущее время с двумя заданными временными диапазонами в текстовом поле. C#
I have two text boxes that contains the time range a of doctor like 20:00 to 04:00. I want to compare these time ranges with the current time to tell if the doctor is available or not.
[^]
Notice the Doctor Timings From 20 00 To 06 00 and the Current time 21:01:54. It is in the range so I'll just print "Available" in Doctor Status. I have stored the doctor's timing in string in "Doctor's Info" using 4 combo boxes and adding the 24 Hour time in collections. Is there a way to make it work or I'll have to redo the timings in DateTime format? If yes then please help with an example code. Thank you.
Что я уже пробовал:
<pre>DateTime time = DateTime.Today; DateTime hr1 = new DateTime(time.Year, time.Month, time.Day, 6, 0, 0); DateTime hr2 = new DateTime(time.Year, time.Month, time.Day, 20, 0, 0); Statusbox.Text = (DateTime.Now > hr1 && DateTime.Now < hr2).ToString();
Настоящий кодекс.