DateTime fromDate;
DateTime.TryParseExact(FromDateTextBox.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out fromDate);
答案 0 :(得分:3)
检查TryParseExact的返回值
bool res = DateTime.TryParseExact(FromDateTextBox.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out fromDate);
if (res == false)
{
//date is not parsable...
}