C# program to display the next day

CsharpProgrammingServer Side Programming

To display the next day, use the AddDays() method and a value +1 to get the next day.

Firstly, use the following to get the current day −

DateTime.Today

Now, add 1 to the AddDays() method to get the next day −

DateTime.Today.AddDays(1)

The following is the code −

Example

 Live Demo

using System;
using System.Collections.Generic;
using System.Linq;
public class Demo {
   public static void Main() {
      Console.WriteLine("Today = {0}", DateTime.Today);
      Console.WriteLine("Previous Day = {0}", DateTime.Today.AddDays(-1));
      Console.WriteLine("Next Day (Tomorrow) = {0}", DateTime.Today.AddDays(1));
   }
}

Output

Today = 9/4/2018 12:00:00 AM
Previous Day = 9/3/2018 12:00:00 AM
Next Day (Tomorrow) = 9/5/2018 12:00:00 AM
raja
Published on 04-Sep-2018 13:42:14
Advertisements