In this answer, We have shared how to calculate someone’s age in C#. Use the following c# code:
1 2 3 4 5 6 | // Save today's date. var today = DateTime.Today; // Calculate the age. var age = today.Year - birthdate.Year; // Go back to the year the person was born in case of a leap year if (birthdate.Date > today.AddYears(-age)) age--; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.