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
TimeSpan.From methods in C# ()
The TimeSpan.From methods include FromDays, FromHours, FromMinutes, etc.
To get the TimeSpan for all the methods
// Days TimeSpan t1 = TimeSpan.FromDays(1); // Hours TimeSpan t2 = TimeSpan.FromHours(1); // Minutes TimeSpan t3 = TimeSpan.FromMinutes(1);
The following is the code that works on all the TimeSpan methods −
Example
using System;
using System.Linq;
public class Demo {
public static void Main() {
TimeSpan t1 = TimeSpan.FromDays(1);
TimeSpan t2 = TimeSpan.FromHours(1);
TimeSpan t3 = TimeSpan.FromMinutes(1);
Console.WriteLine(t1);
Console.WriteLine(t2);
Console.WriteLine(t3);
}
}
Output
1.00:00:00 01:00:00 00:01:00
Advertisements
