C# script user input mask | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

C# script user input mask

Hi all, I have wrote a script to calculate the time difference between two times. The user needs to give input for this. Now to make it more easy I want to be able if the user enters 8 for example my script will convert this value to 8:00 (a time value). Can someone assist me on this? Another option is to add the ":" automatically as a mask. Below you can find a snip of my code: string Pattern = "H:mm"; Console.Write("Enter start time (H:mm): "); DateTime StartTime = DateTime.ParseExact(Console.ReadLine(), Pattern, null); The expected value now is something like: 8:00. If the user needs to enter a lot of values it will be a plus to accept just "8". Thanks in advance!

6th Sep 2018, 9:19 PM
Yannick Bollen
Yannick Bollen - avatar
1 Answer
+ 1
This may help you. I know how to find other programmers to solve problems. I design Visual Basic, C# and C++ Applications. I have already received all certificates from SoloLearn. So in my spare time I go through the courses again to learn things I have missed the first. I am using C# and i Want to read some data that separated with some characters for example : "IP@DOMAIN;USERNAME:PASSWORD" but it's different in each list that user give so i want to try to get the mast with a mask list the example i use something like this to read the list string[] lines = File.ReadAllLines("PathToTheList"); foreach(string line in lines){reading line
6th Sep 2018, 10:55 PM
Lloyd L Conley
Lloyd L Conley - avatar