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

NextSunday

Get's the date of the upcoming Sunday.

Source

public static DateTime NextSunday(this DateTime dt)
{
    return new GregorianCalendar().AddDays(dt, -( (int)dt.DayOfWeek ) + 7);
}

Example

var nextSunday = DateTime.Now.NextSunday();

Author: Charles Cherry

Submitted on: 3 mrt 2011

Language: C#

Type: System.DateTime

Views: 6001