[C#] C#根据出生日期计算年龄的代码 →→→→→进入此内容的聊天室

来自 , 2019-08-05, 写在 C#, 查看 110 次.
URL http://www.code666.cn/view/cd6ce2f9
  1. public int CalculateAgeCorrect(DateTime birthDate, DateTime now)
  2. {
  3.     int age = now.Year - birthDate.Year;
  4.     if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day)) age--;
  5.     return age;
  6. }
  7. //csharp/8435

回复 "C#根据出生日期计算年龄的代码"

这儿你可以回复上面这条便签

captcha