The root cause of random number calculation is the number of random seeds. I used to use the time in milliseconds, but if the time is too fast, it will lead to the same number.
If the number of calls is added as a parameter:
Asp tutorial. net application
<% @ Page language = "c #" contenttype = "text/html" responseencoding = "gb2312" %>
<Script runat = "server">
Void page_load (object sender, eventargs e ){
Random objrandom = new random ();
Label_1.text = convert. tostring (objrandom. next (1, 100 ));
}
</Script>
Test instance
Public static class getint
{
Public static int c;
Public static int getone ()
{
C ++;
Random ran = new random (datetime. now. millisecond + c );
Return ran. next (0, getarg. getmax ());
}
}
Official website instances
Byte [] bytes1 = new byte [2, 100];
Byte [] bytes2 = new byte [1, 100];
Random rnd1 = new random ();
Random rnd2 = new random ();
Rnd1.nextbytes (bytes1 );
Rnd2.nextbytes (bytes2 );
Console. writeline ("first series :");
For (int ctr = bytes1.getlowerbound (0 );
Ctr <= bytes1.getupperbound (0 );
Ctr ++ ){
Console. write ("{0, 5}", bytes1 [ctr]);
If (ctr + 1) % 10 = 0) console. writeline ();
}
Console. writeline ();
Console. writeline ("second series :");
For (int ctr = bytes2.getlowerbound (0 );
Ctr <= bytes2.getupperbound (0 );
Ctr ++ ){
Console. write ("{0, 5}", bytes2 [ctr]);
If (ctr + 1) % 10 = 0) console. writeline ();
}