///
/// 根据出生日期计算年龄
///
///
///
public static 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;
}
C#计算年龄
最新推荐文章于 2024-06-12 20:56:44 发布