-4

我如何使日期/时间仍然计数?我已经尝试过以下代码:

dateTimeContainer.Text = Convert.ToString(DateTime.Now);

但是,当我运行程序时,日期/时间在我们运行程序时停止。

问题:即使在程序运行后,我如何使该日期/时间仍然计数?

4

1 回答 1

4

An instance of DateTime represents a moment in time, once created it is immutable (any "modifying" methods—eg. DateTime.AddHours— return a new DateTime instance rather than changing the subject of the call).

While this immutability might occasionally be something to work around more often than not it is more useful (eg. remembering when some event happened).

If you want to update just read from DateTime.Now (or DateTime.UtcNow) again.

于 2013-09-03T09:28:14.433 回答