The following piece of code gives me the following error:
"Unhandled Exception: string was not recognized as a valid DateTime.
There is an unknown word starting at index 0."
How can I convert the string to DateTime properly here?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter your birthday in format(dd.mm.yyyy): ");
DateTime userBirthday = DateTime.Parse(Console.ReadLine());
long result = DateTime.Today.Subtract(userBirthday).Ticks;
Console.WriteLine("You are {0} years old.", new DateTime(result).Year - 1);
Console.WriteLine("After 10 years you will be {0} years old.", new DateTime(result).AddYears(10).Year - 1);
}
}
}