C# – DateTime expired check


I'm trying to build an extension that will check if a specific date is expired (compared to today's date).

Example: DateTime.Now is: 10/26/2013 11:34:59 AM

If specific datetime is: 10/22/2013 11:34:59 AM then return true (expired)

If specific datetime is 10/28/2013 11:34:59 AM then return false (not expired)

Is this a proper way to do it? (to compare time also because I don't need just the date)

public static bool IsExpired(this string specificDate)
   bool flag = false;
   DateTime currentDate = DateTime.Now;

   DateTime target;

   if (DateTime.tryParse(specificDate, out target)
     flag = target < currentDate;          

   return flag;     

Best Solution

Try this:

public static bool IsExpired(this DateTime specificDate)
   return specificDate < DateTime.Now;