//Example 2 - Validate Date for the format MM/DD/YYYY
private bool ValidateDate(string stringDateValue)
{
try
{
CultureInfo CultureInfoDateCulture = new CultureInfo("en-US");
DateTime d = DateTime.ParseExact(stringDateValue, "MM/dd/yyyy", CultureInfoDateCulture);
return true;
}
catch
{
return false;
}
}
如何在不使用 try 和 catch 的情况下设置此代码工作?