ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Determines if a date is within a given date range


public static bool IsInRange(this DateTime currentDate, DateTime beginDate, DateTime endDate)
    return ( currentDate >= beginDate && currentDate <= endDate );


var monday = DateTime.Now.ThisWeekMonday();
var friday = DateTime.Now.ThisWeekFriday();

If (DateTime.Now.IsInRange(monday, friday) {
    ...do something...

Author: Charles Cherry

Submitted on: 3 mrt 2011

Language: C#

Type: System.DateTime

Views: 7640