

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- MySQL difference between two timestamps in Seconds?
- Difference between two timestamps in seconds in MySQL?
- How to get time difference between two timestamps in seconds?
- Get the difference between two timestamps in seconds in MySQL?
- C# Program to get the difference between two dates in seconds
- Format TimeSpan in C#
- C# TimeSpan Min value
- C# TimeSpan Max value
- Java Program to get the difference between two time zones by seconds
- How to convert JavaScript seconds to minutes and seconds?
- C# Program to Subtract Two TimeSpan
- C# Program to Add Two TimeSpan
- Python program to convert seconds into hours, minutes and seconds
- Converting seconds into days, hours, minutes and seconds in C++
- Difference between JCoClient and JCoDestination
Advertisements