User date input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

User date input

Hi there, I`m wondering how to prompt the user for date input and how to store the data? I`m going to write some code witch main role is going to be comparing the inputed date with actual date. Do you think simple DateTime.Parse... will do the job? Appreciated for any tips and tricks.

16th Dec 2019, 10:47 PM
Vendetta
Vendetta - avatar
3 Answers
+ 3
It really depends how monkey proof your application need to be. Is it enough to just return "Wrong date input" or do you want to give more information to the user like "Invalid month value" DateTime.Parse can be enough also be aware of DateTime.TryParse https://www.dotnetperls.com/datetime-tryparse I think you should print the expected datetimeformat like "yyyy-mm-dd" so the user does not have to guess. Or you can ask 3 questions first yearinput second monthinput third dayinput This can be helpfull or really boring. There is not a right way to do it, you should know what your users are expecting.
17th Dec 2019, 8:19 PM
sneeze
sneeze - avatar
+ 1
Thanks for the answer, it was very helpful. For now it's only a practice task but if it will work the way i want it to maybe some of my co-workers could use it to make somethings a bit easier and faster.
17th Dec 2019, 8:46 PM
Vendetta
Vendetta - avatar
0
Hello, you izuchaej C#
18th Dec 2019, 10:48 AM
Kino. TV
Kino. TV - avatar