I´m coding in C# and have done a Windows form with a few texteboxes and a combobox. I want to create a method that gets the current time and depending on the time sets the value in the combobox. In the combobox there are three values:
TimeZone 1
TimeZone 2
TimeZone 3
I have a code that gets the current time:
string CurrentTime = DateTime.Now.ToString("hh:mm");
And want to create a if statment (if its the best?) that gets the current time and sets the value in the combobox.
if the time are:
06:00 - 14:00 the combobox will get the value TimeZone 1
14:01 - 22:00 the combobox will get the value TimeZone 2
22:01 - 05:59 the combobox will get the value TimeZone 3
Any ideas of how to do this?
Literally what you said there in the question. Dont attempt to convert it to string and parse it again, it will just make your life harder. Here is a sample code logic
Try this