首页 > 电脑

c#windows窗体输入年份和月份,输出该月天数

更新时间2019-12-23 07:57:34

程序

       private void Button3_Click(object sender, EventArgs e)

        {

            int year = Convert.ToInt32(textBox1.Text);

            int month= Convert.ToInt32(textBox2.Text);        

            int []n =new int[]{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            if (month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || year % 400 == 0))

                n[1]++;

            label1.Text = n[month - 1].ToString();      

        }

结果

c#windows窗体输入年份和月份,输出该月天数

上一篇:VC++:Debug出错,提示错误在findfile.cpp

下一篇:资料定量分析主要有哪些类型?其中哪些属于单变量分析,哪些属于双变量分析、多变量分