I'm writing a small console program that calculates your age and I will add some other things later, but the problem is that this code does not calculates the age properly, it just substracts actualYear - birthYear, but if you did not had your birthday yet it displays a wrong age, how can I make this sum all the days and months that i have? I tried a lot of things and didn't work :(
Is there any way to do this using an if statement?
using System;
using System.Collections.Generic;
using System.Text;
namespace para_joel
{
public class Person
{
public string name;
public string surname;
public int birthDay;
public int birthMonth;
public int birthYear;
public int Age()
{
int actualYear = DateTime.Now.Year;
int actualMonth = DateTime.Now.Month;
int actualDay = DateTime.Now.Day;
return actualYear - birthYear;
}
}
}