来自GetHashCode的奇怪结果

时间:2016-06-15 19:58:25

标签: c# .net visual-studio gethashcode

class Program
{
    static void Main(string[] args)
    {
        new Wtf { Foo = "FOO" }.GetHashCode();
    }

    private struct Wtf
    {
        public string Foo { get; set; }
        public override int GetHashCode() => new { A = Foo }.GetHashCode();
    }
}

如果我在此设置断点new { A = Foo }.GetHashCode()并打开快速监视窗口,则以下表达式会产生不同的结果:

new { A = Foo }.GetHashCode()
this.GetHashCode()

我做错了什么?

0 个答案:

没有答案