In this article, I will be demonstrating how to add a number of days to a Date in C#.
Here the new date is found by adding using function AddDays().
Here is source code of the C# Program to Add Two Dates . The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
1 2 3 4 5 6 7 8 9 10 |
static void Main(string[] args) { DateTime startDate = new DateTime(2021, 10, 29); Console.WriteLine("Starting Date : {0}", startDate); DateTime endDate = startDate.AddDays(10); Console.WriteLine("Ending Date : {0}\n", endDate); Console.ReadLine(); } |
Output: