Construct random number seed static int getrandomseed () { byte[] bytes = new Byte[4]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider (); Rng. GetBytes (bytes); Return Bitconverter.toint32 (bytes, 0);} Generate random number static int rnd () { random ran = new Random (Getrandomseed ()); int cnt = ran. Next (0,59); return CNT; }
The above is the whole content of this article, I hope you can like, can be helpful to everyone to learn C #.
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
C # generates random numbers of code
This address: http://www.paobuke.com/develop/c-develop/pbk23093.html
Related content in C # to add comments to the PPT document implementation code C # var keyword in detail C # implementation version WinForm calculator C # Operations IIS method collection
C # Simple implementation of a child form passing a value to a parent form in C # to determine whether a class implements an interface C # to solve the problem with the democ# call execution external Program implementation method
C # generates random numbers of code