相关疑难解决方法(0)

Object.ReferenceEquals永远不会命中

谁能告诉我为什么以下情况不会发生?

List<DateTime> timestamps = new List<DateTime>();
timestamps.Add(DateTime.Parse("8/5/2011 4:34:43 AM"));
timestamps.Add(DateTime.Parse("8/5/2011 4:35:43 AM"));
foreach(DateTime x in timestamps)
{
    if (Object.ReferenceEquals(x, timestamps.First()))
    {
        // Never hit
        Console.WriteLine("hello");
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
2
解决办法
457
查看次数

标签 统计

c# ×1