I'm asking the user for birthdate which is 6 digits without /
and -
. How can define datetime to read 6 digits ddMMyy
??
WriteLine("Write Your birthday using unly number and 6 digits 'ddMMyy'")
string userinput = ReadLine();
DateTime bday = DateTime.Parse(userinput);
WriteLine($"Your birthday is: {bday}");
Outputs:
Unhandled exception. System.FormatException: String '041197' was not recognized as a valid DateTime.
No it's not a duplicate. This didnt answer my question "stackoverflow.com/questions/15738608/…" But answers on this post solved it !