- 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
Difference between TimeSpan Seconds() and TotalSeconds()
TimeSpan Seconds() is part of time, whereas TimeSpan TotalSeconds() converts entire time to seconds.
Let us first see the TimeSpan Seconds() method.
Example
using System; using System.Linq; public class Demo { public static void Main() { TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0); // seconds Console.WriteLine(ts.Seconds); } }
Output
20
Now, let us see how TotalSeconds works for the same TimeSpan value.
Example
using System; using System.Linq; public class Demo { public static void Main() { TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0); // total seconds Console.WriteLine(ts.TotalSeconds); } }
Output
360020
Now, we will see both of them in the same example.
Example
using System; using System.Linq; public class Demo { public static void Main() { TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0); // seconds Console.WriteLine(ts.Seconds); // total seconds Console.WriteLine(ts.TotalSeconds); } }
Output
20 360020
Advertisements