刚刚写完,贴一下啦 public static bool TryTime(string s)
{
DateTime t = DateTime.Now;
return TryTime(s, ref t);
} public static bool TryTime(object o)
{
return TryTime(o.ToString());
} public static bool TryTime(object o, ref DateTime t)
{
return TryTime(o.ToString(), ref t);
} public static bool TryTime(string s, ref DateTime t)
{
try
{
t = DateTime.Parse(s);
return true;
}
catch
{
return false;
}
}