I just read this article on msdn. Article
Determining the span between two dates
Example
Datetime olddate = new datetime (2002,7, 15); datetime newdate = datetime. now; // difference in days, hours, and minutes. timespan Ts = newdate-olddate; // difference in days.int differenceindays = ts. days; console. writeline ("difference in days: {0}", differenceindays );
After reading some examples, I found that new is required for everything: (, It's really troublesome .)
The spacing during the day can be obtained in this way, which is troublesome.
Int differenceindays = ts. Days; returns the number of days that are different between two days,
Int diffhour = ts. hours; the result is not the total hours differenceindays * 24 in the two-day period, but the comparison of the time directly without considering the date. Now it is, the result is 18. Strange.
The same is true in minutes ~~
~~ Make a mark ~~ I will try again tomorrow to find the answer to my questions.