how get yesterday and tomorrow datetime in c#

后端 未结 9 1260
Happy的楠姐
Happy的楠姐 2020-12-13 08:17

I have a code:

int MonthNow = System.DateTime.Now.Month;
int YearNow = System.DateTime.Now.Year;
int DayNow = System.DateTime.Now.Day;

How

9条回答
  •  天涯浪人
    2020-12-13 09:04

    The trick is to use "DateTime" to manipulate dates; only use integers and strings when you need a "final result" from the date.

    For example (pseudo code):

    1. Get "DateTime tomorrow = Now + 1"

    2. Determine date, day of week, day of month - whatever you want - of the resulting date.

提交回复
热议问题