Try this:
private static DateTime LastDayOfMonth( int year, int month )
{
return new DateTime( year, month, DateTimeFormatInfo.CurrentInfo.Calendar.GetDaysInMonth( year, month ) );
}
private static bool IsLastDayOfMonth( DateTime test )
{
DateTime lastDayOfMonth = LastDayOfMonth( test.Year, test.Month );
return test.Day == lastDayOfMonth.Day;
}
private static bool IsLastWorkingDayOfMonth( DateTime test )
{
DateTime lastWorkingDayOfMonth = LastDayOfMonth( test.Year, test.Month );
while ( lastWorkingDayOfMonth.DayOfWeek == DayOfWeek.Saturday ||
lastWorkingDayOfMonth.DayOfWeek == DayOfWeek.Sunday )
{
lastWorkingDayOfMonth = lastWorkingDayOfMonth.AddDays( -1 );
}
return test.Day == lastWorkingDayOfMonth.Day;
}