C# 程序来显示第二天
要显示第二天,请使用 AddDays() 方法和值+1 来获取第二天。
首先,使用以下方法获取当前日期−
DateTime.Today
现在,在 AddDays() 方法中添加 1 来获取第二天−
DateTime.Today.AddDays(1)
以下是代码−
示例
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)); } }
输出
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
广告