C# Program to get the absolute value of the time

CsharpProgrammingServer Side Programming

To get the absolute value of time, use the TimesSpan Duration() method.

Let’s say the following is our TimeSpan.

TimeSpan ts = new TimeSpan(-7, -50, -25);

Now to get the absolute value.

TimeSpan duration = ts.Duration();

Let us see the complete code.

Example

 Live Demo

using System;
using System.Linq;
public class Demo {
   public static void Main() {
      TimeSpan ts = new TimeSpan(-7, -50, -25);
      TimeSpan duration = ts.Duration();
      Console.WriteLine(duration);
   }
}

Output

07:50:25
raja
Published on 12-Sep-2018 12:21:39
Advertisements