C# function will determine if the date is a weekend

//C# function will determine if the date is a weekend


/******************************************************************************/
/*...........This method gives weekend true if the day is 'Sunday' i.e. Day is first day of week.*/


public static bool isWeekend(DateTime adSource)
{

if (dayOfWeek(adSource) == 0)
return true;
else
return false;

}


Comments

Author: Ap03 Sep 2010 Member Level: Bronze   Points : 1

Always these "if(x) return true" functions leading to 4 lines of code when 1 will do and is faster:

public static bool isWeekend(DateTime adSource)
{
return dayOfWeek(adSource) == 0;
}



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: