- using ConsoleApp1;
- using System;//程式庫呼叫
- using System.ComponentModel.DataAnnotations;
- using System.Linq.Expressions;
- using ABC.qq;
- using System.Globalization;
- class Program//負責一部分工作的人
- {
-
- static void Main()
- {
-
- try
- {
- DateTime dt1 = DateTime.ParseExact(Console.ReadLine(), "yyyyMMdd", null);
- DateTime dt2 = DateTime.ParseExact(Console.ReadLine(), "yyyyMMdd", null);
- //TimeSpan:表示一個時間間隔。
- TimeSpan ts =dt2- dt1;
- //將TimeSpan結構所表示的時間間隔換算成等效天數。
- double days = Math.Abs(ts.TotalDays);
- Console.WriteLine(days);
- }
- catch
- {
- Console.WriteLine("error");
- }
-
- }
-
- }
複製代碼 |