C# 计算年龄
2017-06-12 本文已影响0人
QuinShuai
public int CalcAge(DateTime brithday, DateTime today) {
var age = today.Year - brithday.Year;
if (today.Month < brithday.Month || (today.Month == brithday.Month && today.Day < brithday.Day)) {
age--;
}
return age;
}