加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Microsoft不保证Random Edition的实现在.NET版本中保持不

发布时间:2020-12-15 18:29:28 所属栏目:百科 来源:网络整理
导读:引自 online documentation: Notes to Callers: The implementation of the random number generator in the Random class is not guaranteed to remain the same across major versions of the .NET Framework. As a result,your application code should
引自 online documentation:

Notes to Callers: The implementation of the random number generator in
the Random class is not guaranteed to remain the same across major
versions of the .NET Framework. As a result,your application code
should not assume that the same seed will result in the same
pseudo-random sequence in different versions of the .NET Framework.

是什么原因导致Microsoft不保证Random类的实现在.NET版本中保持不变?更具体地说,微软不保证同一种子在主要版本的.NET框架中产生相同的随机数序列的原因是什么?

解决方法

高度投票的帖子存在问题. Random类肯定会产生可预测的数字.从Random(Int32)构造函数的文档:

Providing an identical seed value to different Random objects causes each instance to produce identical sequences of random numbers.

微软不想承诺的是,这个序列在另一个.NET Framework版本中是相同的.这是有充分理由的,他们无法确定他们使用的算法是否完全没有缺陷.使使用Random类的代码易受攻击或易于产生偏差结果的类型.赔率非常低,但不是零.

有一个先例,最臭名昭着的案例是IBM在他们的大型机软件中使用的随机生成器的问题,称为RANDU.被称为“被广泛认为是有史以来设计最错误的随机数发生器之一”.一旦分析师开始更好地审视它,它就有明显的缺陷.它于1963年首次被标记,但在20世纪70年代仍被广泛使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读