Created
January 23, 2019 15:12
-
-
Save khan-hasan/022c966710d8edaf19d88193deeba923 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Console.WriteLine("Enter a time value in the 24-hour time format (e.g. 19:00):"); | |
| var input = Console.ReadLine(); | |
| if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input)) | |
| Console.WriteLine("Invalid Time"); | |
| var lowTime = DateTime.Parse("00:00"); | |
| var highTime = DateTime.Parse("23:59"); | |
| var inputTime = DateTime.Parse(input); | |
| try | |
| { | |
| if (inputTime >= lowTime && inputTime <= highTime) | |
| Console.WriteLine("Ok"); | |
| else | |
| Console.WriteLine("Invalid Time"); | |
| } | |
| catch (Exception e) | |
| { | |
| Console.WriteLine("Generic Exception Handler: {0}", e.ToString()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment