阅读背景:

C# 根据出生日期(年月日)计算年龄的代码

来源:互联网 
    public int GetAgeByBirthdate(DateTime birthdate)
    {
        DateTime now = DateTime.Now;
        int age = now.Year - birthdate.Year;
        if (now.Month < birthdate.Month || (now.Month == birthdate.Month && now.Day < birthdate.Day))
        {
            age--;
        }
        return age < 0 ? 0 : age;
    }    public int GetAgeByBirthdate(DateTime birth



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: