閱讀381 返回首頁    go 阿裏雲 go 技術社區[雲棲]


C#輸入年份,判斷閏年平年

private void btnJudge_Click(object sender, EventArgs e)
        {
            uint uiYear;
            if (uint.TryParse(txtYear.Text, out uiYear))
            {
                if (uiYear % 4 == 0 && uiYear % 100 != 0 || uiYear % 400 == 0)
                {
                    MessageBox.Show("是閏年");
                    return;
                }
                else
                {
                    MessageBox.Show("是平年");
                    return;
                }
            }
            else
            {
                MessageBox.Show("輸入的不是合法的年份");
                return;
            }

        }

最後更新:2017-04-02 00:06:49

  上一篇:go JSP基礎2
  下一篇:go JSP基礎7