而不是使用:
int noOfDaysInMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
我想使用传入的 2 个值来获取一个月的天数:
public ActionResult Index(int? month, int? year)
{
DateTime Month = System.Convert.ToDateTime(month);
DateTime Year = System.Convert.ToDateTime(year);
int noOfDaysInMonth = DateTime.DaysInMonth(Year, Month);
(Year, Month) 被标记为无效参数?有任何想法吗?也许system.conert.todatetime.month?