Computer >> Computer tutorials >  >> Programming >> C#

C# DateTime to add days to the current date


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

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