Vijay

Vijay

  • NA
  • 150
  • 90.5k

Calculate age In C#

Aug 13 2013 3:47 AM
Please can you help me in console application.
How to calculate age from DOB

 class Personal{
 public DateTime DateOfBirth { get; set; }
 public string Age { get; set; }
 }

        Personal per=new Personal();
       Console.WriteLine("Enter the Date Of Birth :",per.DateOfBirth);       
 per.DateOfBirth = DateTime.Parse(Console.ReadLine());



 public string GetAge(DateTime DateOfBirth)
         {
        }

How can i write for function to calculate age from DOB and display

       Console.WriteLine("The DOB is" +DateOfBirth);
       Console.WriteLine("the Age is ...." +Age);

DOB is 04/02/1994
i want display age is 19 years, 6 months, and 9 days



Thanks.

Answers (11)