让用户以下午 3:30 的格式输入到达时间,然后询问用户需要多长时间才能到达目的地。然后我需要显示他们需要离开的时间才能准时到达目的地。
到目前为止我有这个
Console.WriteLine("Enter the arrival time <e.g. 3:30 PM>:");
DateTime time = Convert.ToDateTime(Console.ReadLine());
Console.WriteLine("How long is the trip time in minutes:");
string date = Console.ReadLine();
DateTime durationOfTrip = DateTime.Parse(date);
TimeSpan diff = time.Subtract(durationOfTrip);
Console.WriteLine(diff);
Console.ReadLine();
我收到此错误类型未处理的异常System.FormatException
发生在mscorlib.dll
Additional information: String was not recognized as a valid DateTime.