Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DaysAlive
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime now = DateTime.Now;
- Console.Write("Enter your birthday: ");
- string input = Console.ReadLine();
- if(DateTime.TryParse(input, out DateTime inputDateTime))
- {
- TimeSpan daysPassed = now.Subtract(inputDateTime);
- Console.WriteLine($"Days passed since {inputDateTime.ToShortDateString()}: {daysPassed.Days:n0}");
- }
- else
- {
- Console.WriteLine("Please enter a correct date");
- }
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment