private void Form1_Load(object sender, EventArgs e) { string strDate = "01/10/1981"; DateTime MyBirthDayDate = Convert.ToDateTime(strDate); int Age = CalculateYorAge(MyBirthDayDate); } public static int CalculateYorAge(DateTime birthDaydate) { int yearsAge = DateTime.Now.Year - birthDaydate.Year; if (DateTime.Now.Month < birthDaydate.Month || (DateTime.Now.Month == birthDaydate.Month && DateTime.Now.Day < birthDaydate.Day)) yearsAge--; return yearsAge; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)