Nov 13
最近在忙公司的一个软件的测评,两天都是在陕西软件评测中心过的,好无聊,下午回到公司写了一个计算年龄的函数。哎!赶紧结束吧。发现最近好久没更新技术的东西了,懒惰啊!
[coolcode lang="C#"]
///
/// 年齢の決算
///
///
private int Age(string seiymd)
{
int Seiy = Convert.ToInt32(seiymd.Substring(0, 4));//年
int Seim = Convert.ToInt32(seiymd.Substring(5, 2));//月
int Seid = Convert.ToInt32(seiymd.Substring(8, 2));//日 int nowyr = DateTime.Today.Year;//今の年
int nowmh = DateTime.Today.Month;//今の月
int nowd = DateTime.Today.Day;//今の日
int year=nowyr-Seiy;
if (year > 0)
{
if (nowmh - Seim < 0)
{
year–;
return year;
}
if ((nowmh == Seim) && (nowd - Seid < 0))
{
year–;
return year;
}
}
else
{
year = 0;
}
return year;
}
[/coolcode]

Most Commented