Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑到一个人的年龄(以月为单位),我真的很想计算出生日期。目前,我正在使用 C# 来做到这一点。但是,没能理解其中的逻辑。提前致谢
DateTime 具有从当前日期减去(实际上是添加负值)月份的完美方法。例如:
int ageInMonths = 18; DateTime dt = DateTime.Today; DateTime DateOfBirth = dt.AddMonths(-ageInMonths);