C# program to add and subtract days from the date
In this C# program, we will add and subtract days from the date.
C# program to add and subtract days from the date Code:
private static void Main(string[] args)
{
DateTime StartDate = new DateTime(2022, 1, 1);
DateTime tempDate = StartDate;
Console.WriteLine("Initial Date : {0}", StartDate);
Console.WriteLine();
//--- Add Days to the date
DateTime ADate = tempDate.AddDays(10);
Console.WriteLine("Date after adding 10 days to date : {0}", ADate);
//--- Subtract Days to the date
tempDate = StartDate;
DateTime SDate = tempDate.AddDays(-10);
Console.WriteLine("Date after subtracting 10 days to date : {0}", SDate);
Console.ReadLine();
}
C# program to add and subtract days from the date Output: