老师布置的作业,一直没有完成。现在有一些时间,继续完成它们。其中一题是列出当前月的每一天。

public IEnumerable<DateTime> AllDatesInMonth(int year, int month)
    {
        int days = DateTime.DaysInMonth(year, month);

        for (int i = 1; i <= days; i++)
        {
            yield return new DateTime(year, month, i);
        }
    }

 

相关文章:

  • 2022-12-23
  • 2022-02-26
  • 2021-08-24
  • 2021-08-19
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案