Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. int hours1 = 5;
  2.             int minutes1 = 3;
  3.             TimeSpan timeSpan1 = new TimeSpan(hours1, minutes1, 0);
  4.  
  5.             int hours2 = 5;
  6.             int minutes2 = 4;
  7.             TimeSpan timeSpan2 = new TimeSpan(hours2, minutes2, 0);
  8.  
  9.             if(timeSpan1 > timeSpan2)  // Това > е описано в https://msdn.microsoft.com/en-us/library/system.timespan.op_greaterthan(v=vs.110).aspx
  10.             {
  11.                 Console.WriteLine("timeSpan1");
  12.             }
  13.             else
  14.             {
  15.                 Console.WriteLine("timeSpan2");
  16.             }
  17.  
  18.             // Или пък:
  19.  
  20.             int result = TimeSpan.Compare(timeSpan1, timeSpan2);
  21.             if (result > 0)
  22.             {
  23.                 Console.WriteLine("timeSpan1");
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("timeSpan2");
  28.             }
  29.  
  30.             // Или пък:
  31.  
  32.             if (timeSpan1.Ticks > timeSpan2.Ticks)
  33.                 {
  34.                 Console.WriteLine("timeSpan1");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine("timeSpan2");
  39.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement