fcamuso

TimeSpan

May 16th, 2021
572
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace DateTime_A
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       //TimeSpan, DateTime, DateTimeOffset
  10.      
  11.       DateTime dt1 = DateTime.Now;
  12.       DateTime dt2 = DateTime.Now;
  13.  
  14.       Console.WriteLine(dt1);
  15.       DateTime dt3 = dt1 + TimeSpan.FromDays(5.5);
  16.       Console.WriteLine(dt3);
  17.  
  18.       dt3 = dt3.AddDays(5);
  19.       Console.WriteLine(dt3);
  20.       TimeSpan ts1 = new TimeSpan(10000000); //1s = 10.000.000 di ticks da 100ns
  21.       Console.WriteLine(dt3 + ts1);
  22.       ts1 = dt3 - dt1 + TimeSpan.FromHours(11.999);
  23.  
  24.       Console.WriteLine(ts1.TotalDays);
  25.       Console.WriteLine(ts1.Days);
  26.      
  27.  
  28.  
  29.       //Console.WriteLine(ts1.Ticks);
  30.  
  31.  
  32.  
  33.     }
  34.   }
  35. }
  36.  
RAW Paste Data