编写方法,输出给定日期所在月份的第一天和最后一天

xiaoxiao2021-02-28  53

void Main() { DateTime dt=DateTime.Now; ShowMonthInfo(dt); }

public void ShowMonthInfo(DateTime dt)

{ var begin = new DateTime(dt.Year,dt.Month,1); begin.Dump(); begin.AddMonths(1).AddDays(-1).Dump();

}

结果:

转载请注明原文地址: https://www.6miu.com/read-73689.html

最新回复(0)