![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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