C# DateTime to add days to the current date

CsharpProgrammingServer Side Programming

Firstly, get the current date.

DateTime.Today

Now, use AddDays() method to add days to the current date. Here, we are adding 10 days to the current date.

DateTime.Today.AddDays(10)

Let us see the complete code −

Example

 Live Demo

using System;
using System.Linq;
public class Demo {
   public static void Main() {
      Console.WriteLine("Today = {0}", DateTime.Today);
      Console.WriteLine("Add 10 Days = {0}", DateTime.Today.AddDays(10));
   }
}

Output

Today = 9/11/2018 12:00:00 AM
Add 10 Days = 9/21/2018 12:00:00 AM
raja
Published on 11-Sep-2018 16:43:54
Advertisements