-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
37 lines (30 loc) · 1.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
namespace Lab2
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Please enter a date (Format: august 29, 2018 or 8/29/2018)");
string dateInput1 = Console.ReadLine();
DateTime date1;
while (!DateTime.TryParse(dateInput1, out date1))
{
Console.WriteLine("Invalid! Please enter a date (Format: august 29, 2018 or 8/29/2018)");
dateInput1 = Console.ReadLine();
DateTime.TryParse(dateInput1, out date1);
}
Console.WriteLine("Please enter a date (Format: august 29, 2018 or 8/29/2018)");
string dateInput2 = Console.ReadLine();
DateTime date2;
while(!DateTime.TryParse(dateInput2, out date2))
{
Console.WriteLine("Invalid! Please enter a date (Format: august 29, 2018 or 8/29/2018)");
dateInput2 = Console.ReadLine();
DateTime.TryParse(dateInput2, out date2);
}
TimeSpan span = date2.Subtract(date1);
Console.WriteLine(span);
}
}
}