随机数的最佳种子

编程入门 行业动态 更新时间:2024-10-28 01:12:36
本文介绍了随机数的最佳种子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道默认情况下随机数生成器使用时间,但是我可以在我的网络应用程序中使用的最佳种子是什么? 程序生成6个唯一的随机数,并在 文本框控件中加载它们。我需要一个好的种子,如IP地址或其他东西。 ''生成随机数的函数 公共函数GetRandomNumber()As Integer Dim objRandom As New System.Random 返回objRandom.Next(1,26) 结束功能

I know by default the random number generator use the time, but what is the best seed I can used in my web application? The Program generate 6 unique random numbers and load each of them in a textbox control. I need a good seed like ip address or something. ''Function to generate random numbers Public Function GetRandomNumber() As Integer Dim objRandom As New System.Random Return objRandom.Next(1, 26) End Function

推荐答案

" Leon" < VN ***** @ msn>在消息中写道 新闻:Ox ************** @ TK2MSFTNGP11.phx.gbl ... "Leon" <vn*****@msn> wrote in message news:Ox**************@TK2MSFTNGP11.phx.gbl... 我默认知道随机数生成器使用时间,但是什么是我可以在我的网络应用程序中使用的最佳种子? 程序生成6个唯一的随机数并在文本框控件。我需要一个好的种子,如IP地址或其他东西。 ''生成随机数的函数 公共函数GetRandomNumber()作为整数 昏暗objRandom As New System.Random 返回objRandom.Next(1,26) 结束功能 I know by default the random number generator use the time, but what is the best seed I can used in my web application? The Program generate 6 unique random numbers and load each of them in a textbox control. I need a good seed like ip address or something. ''Function to generate random numbers Public Function GetRandomNumber() As Integer Dim objRandom As New System.Random Return objRandom.Next(1, 26) End Function

我不是知道这是否是最佳但我使用(这是一个随机数 字符串格式)另外你可以将8改为更高的数字更大的 Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype(right(strID,8),int32)) strUnique = rdm1.next()。tostring()

I don''t know if this is best or not but I use (this is for a random number in string format) Also you can change the 8 to a higher number for a larger random number. Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype(right(strID,8),int32)) strUnique = rdm1.next().tostring()

为什么选择ticks(long)并将其作为字符串转换为仅将其转换为 整数? 为什么只选择正确的8个字符而不是整个值? 将myRandom调暗为新随机(CType(Now.Ticks,Integer)) 将theNumber调暗为Intege r = myRandom.Next Why take ticks (long) and cast as a string only to cast it back to an Integer? Why take only the right 8 chars and not the whole value? Dim myRandom As New Random(CType(Now.Ticks, Integer)) dim theNumber as Integer = myRandom.Next

我不知道这是不是最好但是我用(这个是字符串格式的随机数也可以将8更大的数字更改为更大的随机数。 Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype(right(strID,8),int32)) strUnique = rdm1.next()。 tostring()

I don''t know if this is best or not but I use (this is for a random number in string format) Also you can change the 8 to a higher number for a larger random number. Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype(right(strID,8),int32)) strUnique = rdm1.next().tostring()

" Scott M." < S - *** @ nospam.nospam>在留言中写道 新闻:%2 **************** @ tk2msftngp13.phx.gbl ... "Scott M." <s-***@nospam.nospam> wrote in message news:%2****************@tk2msftngp13.phx.gbl... 为什么选择ticks(long)并作为一个字符串强制转换为整数?为什么只选择正确的8个字符而不是整个值? Dim myRandom As新的随机(CType(Now.Ticks,整数))将数字调整为整数= myRandom.Next Why take ticks (long) and cast as a string only to cast it back to an Integer? Why take only the right 8 chars and not the whole value? Dim myRandom As New Random(CType(Now.Ticks, Integer)) dim theNumber as Integer = myRandom.Next

我不知道这是不是最好但是我使用(这是一个字符串格式的随机数字)另外你可以将8更改为更高的数字/>更大随机数。 Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype (右(strID,8),int32)) strUnique = rdm1.next()。tostring()

I don''t know if this is best or not but I use (this is for a random number in string format) Also you can change the 8 to a higher number for a larger random number. Dim strID as string = DateTime.Now.Ticks.tostring() Dim rdm1 as Random rdm1 = new Random(ctype(right(strID,8),int32)) strUnique = rdm1.next().tostring()

我这样做因为我想要一个16个字符的字符串,后来在 代码(不包括在内)中添加了剩下的人物。另外我想如果你使用 整个刻度它对于Random来说太大了。

Well I do this because I wanted a 16 character string and later on in the code (not included) I add the remaining characters. Also I think if you use the whole tick it was too big for Random.

更多推荐

随机数的最佳种子

本文发布于:2023-11-08 08:10:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568832.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:随机数   种子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!