- 热门分类
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
广告