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;
}
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;
}
本文标题:C# 计算年龄
本文链接:https://www.haomeiwen.com/subject/ijalqxtx.html
网友评论