C# 怎样将DateTime类型进行日期的加减

C#中 DateTime类型有封装好的函数 例如:

        //将当前时间转换为指定格式的DateTime类型
        DateTime dt=DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
        //将当前日期减一天
        dt.AddDays(-1);
        //将当前日期减一个月
        dt.AddMonths(-1);
        //将当前日期减一年
        dt.AddYears(-1);

原文地址:https://www.cnblogs.com/haxianhe/p/9271195.html