Why datetime cannot compare?
问题 my C# unit test has the following statement: Assert.AreEqual(logoutTime, log.First().Timestamp); Why it is failed with following information: Assert.AreEqual failed. Expected:<4/28/2010 2:30:37 PM>. Actual:<4/28/2010 2:30:37 PM>. Are they not the same? Update: Use this if you only care to second: Assert.AreEqual(logoutTime.ToString(), log.First().Timestamp.ToString()); 回答1: Have you verified that the number of ticks/milliseconds are equal? If you do DateTime.Now() twice back to back, they