Converting someone's age into leap days

So I'm trying to create a simple console app that will determine the users age in days, hours, minutes and seconds and was able to get all 4 done, but I was wondering if there was any to use TimeSpan and still be able to get a leap days calculation. If that makes any sense

//Gretting user and asking to enter name   Console.WriteLine("Hello! What is your name? \t "); //assigning   string Name = Console.ReadLine(); //outputing what user entered   Console.WriteLine("Hello {0}!", Name); //This will ask and make sure they are entering a valid date   while (true)          {             Console.Write("Enter your birtdate in the following format (MM/DD/YYYY): ");             DateTime Birth;             //Using TimeSpan to detmermine Age in days, hours, minutes, seconds             if (DateTime.TryParse(Console.ReadLine(), out Birth))             {                 TimeSpan Age = DateTime.Now - Birth;                 Console.WriteLine("You've been alive for {0} days!", (int)(Age.Days));                 Console.WriteLine("You've been alive for {0} hours!", (int)(Age.TotalHours));                 Console.WriteLine("You've been alive for {0} minutes!", (int)(Age.TotalMinutes));                 Console.WriteLine("You've been alive for {0} seconds!", (int)(Age.TotalSeconds));             }             //This is to make sure, again, they are entering a valid date             else                 Console.WriteLine("You have entered an invalid date." + Environment.NewLine);         } 

Replay

Category: c# Time: 2016-07-28 Views: 0
Tags:

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.128 (s). 12 q(s)