更新时间:1970-01-01 07:59:30
添加两个日期后您会得到什么?
3月3日+下星期二等于多少?我不知道,我也不认为你知道.因为很傻.就像在光年中添加橘子一样!
考虑一下:您实际上要实现什么?
What do you expect to get when you add two dates?
What is 3rd March + next Tuesday equal to? I don''t know, and I don''t think you do. Because it is silly. It is like adding oranges to lightyears!
Think about it: what are you actually trying to achieve?
您使用^ ]和 TimeSpan [
You use DateTime[^] and TimeSpan[^] structs
But you cannot add a DateTime to another DateTime. You can add a TimeSpan to a DateTime.
DateTime now = DateTime.Now;
DateTime arrive = now + new TimeSpan(2, 30, 0); // Add 2 hours and 30 min.
将add key="DateTime"
更改为TimeSpan
.
Change add key="DateTime"
to TimeSpan
.
按照此处 [^ ] .
然后使用DateTime.Add
方法将此值添加到另一个日期.
Read this date as described here[^].
Then add this value to another date using theDateTime.Add
method.