public static bool SalStrToDateTime(string ValueToDate)
{
if (ValueToDate != null)
{
try
{
DateTime.Parse(ValueToDate.Substring(0,10));
return true;
}
catch
{
try
{
DateTime.Parse(ValueToDate.Substring(0, 9));
return true;
}
catch
{
try
{
DateTime.Parse(ValueToDate.Substring(0, 8));
return true;
}
catch
{
return false;
}
}
}
}
else
{
return false;
}
}
巧妙的运用了subString()方法