In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how C # implements the calculation of time intervals. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
C # interval calculation can be implemented through the timescale class TimSpan, which is a system class.
Examples of C # time interval calculation:
Realize the calculation of C# time interval between two times:
TimeSpan ts1 = new TimeSpan (DateTime.Now.Ticks); / / get the number of ticks of the current time / / your code or other operations TimeSpan ts2 = new TimeSpan (DateTime.Now.Ticks); TimeSpan ts = ts2.Subtract (ts1). Duration (); / / absolute value of time difference String spanTime = ts.Hours.ToString () + "hours" + ts.Minutes.ToString () + "minutes" + ts.Seconds.ToString () + "seconds" / / actual execution time in the format of X hours, X minutes and X seconds
Some instructions for the calculation of the C# interval:
The TimeSpan value contains a number of properties and methods for accessing or processing a timespan value
The following list covers some of them:
Add: added to another timespan value.
Days: returns the timespan value calculated in days.
Duration: gets the absolute value of TimeSpan.
Hours: returns the timespan value calculated in hours
Milliseconds: returns the timespan value in milliseconds.
Minutes: returns the timespan value calculated in minutes.
Negate: returns the opposite number of the current instance.
Seconds: returns the timespan value calculated in seconds.
Subtract: subtracts another timespan value from it.
Ticks: returns the number of tick of the timespan value.
TotalDays: returns the number of days represented by the timespan value.
TotalHours: returns the number of hours represented by the timespan value.
TotalMilliseconds: returns the number of milliseconds represented by the timespan value.
TotalMinutes: returns the number of minutes represented by the timespan value.
TotalSeconds: returns the number of seconds represented by the timespan value.
Thank you for reading! This is the end of the article on "how to calculate the time interval in C#". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.