static DateTime now = new DateTime(2019,7,31).AddHours(23).AddMinutes(59).AddSeconds(58);
public static void Main()
DateTime exp = new DateTime(2019, 7,DateTime.DaysInMonth(2019, 7));
Console.WriteLine("exp date:" + exp);
bool valid = IsCardValid(exp);
Console.WriteLine("isValid:" + valid);
private static bool IsCardValid(DateTime date)
DateTime expDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)).AddHours(23).AddMinutes(59).AddSeconds(59);
Console.WriteLine("expdate:" + expDate);