Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Program to get the absolute value of the time
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
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
Advertisements
