Mega Code Archive

 
Categories / C# / Date Time
 

Add one week to the current date

using System; public class DateArithmetic {    public static void Main()    {         DateTimeOffset workDay = new DateTimeOffset(2008, 3, 1, 9, 0, 0, DateTimeOffset.Now.Offset);         int month = workDay.Month;         do             {            Console.WriteLine("   {0:dddd}, {0:MMMM}{0: d}", workDay);            workDay = workDay.AddDays(7);         } while (workDay.Month == month);     } }