1
DateTime fromDate;
DateTime.TryParseExact(FromDateTextBox.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out fromDate);
4

1 回答 1

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...
}
于 2013-05-20T06:29:27.280 回答