Is there a way to make .NET Core GetHashCode deterministic

后端 未结 2 944
长情又很酷
长情又很酷 2021-01-02 01:10

I just wasted few hours of debugging before realizing that contrary to .NET, in .NET Core, GetHashCode returns a different value every time you run your code. I totally unde

2条回答
  •  既然无缘
    2021-01-02 01:43

    The pragmatic solution I have found to get string.GetHashCode to return predicable values across multiple executions is simply to switch back to classic .NET (4.6). Since there is nothing .NET Core specific about my code, the only work I had to do was create a new project. I debugged my code under .NET 4.6, fixed the bug and switched back to Core.

提交回复
热议问题