首页 > 其他 > 详细

C#根据出生日期计算年龄

时间:2014-10-09 01:44:18      阅读:420      评论:0      收藏:0      [点我收藏+]

public int CalculateAge(DateTime birthDate, DateTime now)
        {
            int age = now.Year - birthDate.Year;
            if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))
            {
                age--;
            }
            return age;
        }

C#根据出生日期计算年龄

原文:http://1030967291.blog.51cto.com/6293718/1561277

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!