Home > Backend Development > C#.Net Tutorial > The difference between Minutes and TotalMinutes in C#

The difference between Minutes and TotalMinutes in C#

黄舟
Release: 2017-09-16 11:07:04
Original
5073 people have browsed it

A bug was mentioned in today's test, saying that the timing of the message reminder was wrong. It was set 2 hours in advance, and the reminder was issued before it arrived.

Looked at the code


(m.ExpectReceiveTime - DateTime.Now).Minutes < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))
Copy after login

Executed


##

(m.ExpectReceiveTime - DateTime.Now).Minutes
Copy after login

The result is 55, logically it should It is 170

Execution


(m.ExpectReceiveTime - DateTime.Now).TotalMinutes
Copy after login

The result is 169.89568451

Finally modify the code to


(Convert.ToDecimal((m.ExpectReceiveTime - DateTime.Now).TotalMinutes) < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))
Copy after login

BUG SOLVED

Supplement:

Days;              //天部分 Hours; //小时部分
Milliseconds;      //毫秒部分
Minutes;           //分部分
Seconds;           //秒部分
Ticks;             //Tick 总数
TotalDays;         //总天数
TotalHours;        //总小时数
TotalMilliseconds; //总毫秒数
TotalMinutes;      //总分钟数
TotalSeconds;      //总秒数
Copy after login

The above is the detailed content of The difference between Minutes and TotalMinutes in C#. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template