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

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;
        }

成都创新互联公司主营南木林网站建设的网络公司,主营网站建设方案,成都App制作,南木林h5小程序开发搭建,南木林网站营销推广欢迎南木林等地区企业咨询


本文题目:C#根据出生日期计算年龄
网页链接:http://myzitong.com/article/jdgdgh.html