Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个日期:
2012 年 6 月 26 日上午 12:13 和 2012 年 7 月 31 日下午 12:54
我需要比较这两个日期并提取它们之间的天数(差异)
使用时间跨度
TimeSpan difference = dateTime1 - dateTime2;
difference.TotalDays会给你天数
difference.TotalDays
var days = difference.TotalDays;