I'm trying to figure out how to calculate
the current year minus the birth year to calculate age
namespace howOldAreYou
{
class Program
{
public static void Main(string[] args)
{
//variables
int birthYear;
string name;
System.DateTime moment = new System.DateTime();
int year = moment.Year;
//int month = moment.Month;
//int day = moment.Day;
//int minute = moment.Minute;
//int second = moment.Second;
//int millisecond = moment.Millisecond;
//Find out person's name
Console.WriteLine("What is your name?");
name = Console.ReadLine();
//Find what year person was born
Console.WriteLine("What year were you born, " + name + "?" );
if (int.TryParse(Console.ReadLine(), out birthYear))
{
Console.WriteLine(birthYear + "! Well you must be " + (year - birthYear));
}
else
{
Console.WriteLine("Sorry that's an invalid year");
}
}
}
}