Implementation change to .NET's Random()

前端 未结 5 845
清歌不尽
清歌不尽 2021-01-11 09:25

I am migrating a method that is used for decoding from .NET Framework 1.1 to .NET Framework 4. I noticed that implementation of Random changed. So given the same seed, Rando

5条回答
  •  借酒劲吻你
    2021-01-11 10:06

    This is not a problem with Random, it satisfies its documented interface perfectly fine. This is a problem with your software relying on an implementation detail. Learn from this mistake and don't do it again.

    As far as fixing the problem, you can implement your own version of 1.1's pseudorandom number generation for decoding and then implement a new encoding/decoding algorithm that doesn't rely on unstable behavior (such as the implementation of Random or GetHashCode) for your new version of the software.

提交回复
热议问题