Learning to use ASP. NET's system. Random class

Source: Internet
Author: User
Tags random seed
Member:
 
Next (); // obtain 0 .. int. the Int Random Number of maxvalue. The value range is nextbytes (). // 0 .. 255 random number and fill in the byte array nextdouble (); // obtain 0 .. double Random Number of 1
Constructor:
// If no random seed is specified, the system generates the seed protected void button1_click (Object sender, eventargs e) {random r = new random (); int n1 = R. next (); int n2 = R. next (); textbox1.text = string. concat (N1, "\ n", N2);} // the random sequence of the seed value is the same as that of protected void button2_click (Object sender, eventargs E) {random R1 = new random (1); random r2 = new random (1); random R3 = new random (2); byte [] BS1 = new byte [10]; byte [] bs2 = new byte [10]; byte [] bs3 = new byte [10]; r1.nextbytes (BS1); r2.nextbytes (bs2); r3.nextbytes (bs3 ); string S1 = string. join (",", BS1); // 70,208,134,130, 64,151,228,163,149,207 string S2 = string. join (",", bs2); // 70,208,134,130, 64,151,228,163,149,207 string S3 = string. join (",", bs3); // 113,147,198,149, 36,185,227,111,124, 56 textbox1.text = string. concat (S1, "\ n", S2, "\ n", S3 );}
Exercise:
Protected void button1_click (Object sender, eventargs e) {random r = new random (0); int n1 = R. next (); /// 1559595546 int n2 = R. next (10); // 8 int N3 = R. next (1000,200 0); // 1768 textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3);} protected void button2_click (Object sender, eventargs e) {random r = new random (0 ); double F; string STR = ""; for (INT I = 0; I
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.