- 熱門分類
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHPPhysics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 精選讀物
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
TimeSpan Seconds() 與 TotalSeconds() 之間的區別
TimeSpan Seconds() 是時間的一部分,而 TimeSpan TotalSeconds() 會將整個時間轉換成秒數。
讓我們首先了解 TimeSpan Seconds() 方法。
示例
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);
}
}輸出
20
現在,讓我們看看 TotalSeconds 如何處理相同的 TimeSpan 值。
示例
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);
}
}輸出
360020
現在,我們將在同一個示例中同時看到它們。
示例
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);
}
}輸出
20 360020
廣告