Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取所选月份';她最后一次在C#net上约会?_C#_Asp.net - Fatal编程技术网

如何获取所选月份';她最后一次在C#net上约会?

如何获取所选月份';她最后一次在C#net上约会?,c#,asp.net,C#,Asp.net,我使用下拉列表在.aspx页面中选择月份。我必须在.aspx.cs页面中获取所选月份的最后日期。(有些月份有30天,有些月份有31天) 我如何才能做到这一点?不需要自定义计算 使用该方法可以找出任何给定月份(也是最后一天)的天数 简单到: //Get days in month 2 (Feb) of year 2011. Returns 28. int daysInFeb2011 = System.DateTime.DaysInMonth(2011, 2); MSDN文档提供了更全面、更具

我使用下拉列表在
.aspx
页面中选择月份。我必须在
.aspx.cs
页面中获取所选月份的最后日期。(有些月份有30天,有些月份有31天)


我如何才能做到这一点?

不需要自定义计算

使用该方法可以找出任何给定月份(也是最后一天)的天数

简单到:

//Get days in month 2 (Feb) of year 2011. Returns 28.
int daysInFeb2011 = System.DateTime.DaysInMonth(2011, 2); 

MSDN文档提供了更全面、更具描述性的示例:

        const int July = 7;
        const int Feb = 2;

        // daysInJuly gets 31.
        int daysInJuly = System.DateTime.DaysInMonth(2001, July);

        // daysInFeb gets 28 because the year 1998 was not a leap year.
        int daysInFeb = System.DateTime.DaysInMonth(1998, Feb);

        // daysInFebLeap gets 29 because the year 1996 was a leap year.
        int daysInFebLeap = System.DateTime.DaysInMonth(1996, Feb);