我在 vb.net 中有一个非常奇怪的问题,由于某种原因 system.random() 在我的任何函数中都不是随机的:
Public Function RandomNumber(ByVal MaxNumber As Integer, Optional ByVal MinNumber As Integer = 0) As Integer
Dim R As System.Random = New System.Random()
If MinNumber > MaxNumber Then
Dim T As Integer = MinNumber
MinNumber = MaxNumber
MaxNumber = T
End If
Return R.Next(MinNumber, MaxNumber)
End Function
这是准确调用 9 次后的结果
4
4
4
3
3
3
3
3
3