In VB6 there is a function IsDate that returns True if the expression is of type Date or is a string convertible to type Date; otherwise, it returns False. Is there such a built-in function in C#?
Thanks.
> Wayne wrote:
>
> In VB6 there is a function IsDate that returns True if the expression is of
> type Date or is a string convertible to type Date; otherwise, it returns
> False. Is there such a built-in function in C#?
> Thanks.
You can use the DateTime.Parse() method. If it throws an exception, it isn't a
date:
try
{
System.DateTime dt = System.DateTime.Parse(str);
}
catch
{
// Not a date, handle appropriately
}
Wayne - 11 May 2004 20:15 GMT
Thanks Julie! It works great.
> > Wayne wrote:
> >
[quoted text clipped - 14 lines]
> // Not a date, handle appropriately
> }