Answers for "c# calculate someone's age"


c# calculate someone's age

// Save today's date.
var today = DateTime.Today;

// Calculate the age.
var age = today.Year - birthdate.Year;

// Go back to the year in which the person was born in case of a leap year
if (birthdate.Date > today.AddYears(-age)) age--;
Posted by: Guest on July-01-2021

C# Answers by Framework

Browse Popular Code Answers by Language