-
判断一个C#应用程序中的年份是否为闰年
资源介绍
C#应用程序判断是否闰年
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btOk_Click(object sender, EventArgs e)
{
btOk.ForeColor = Color.Red;
int year=int.Parse(txtYear.Text);
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
lbSee.Text="您输入的是闰年!";
}
else
{
lbSee.Text="您输入的不是闰年!";
}
}
private void btClear_Click(object sender, EventArgs e)
{
btClear.ForeColor = Color.Blue;
txtYear.Text = "";
lbSee.Text = "";
txtYear.Focus();
}
}
}