C # get random number (randomness class)

Source: Internet
Author: User

C # get random number (randomness class)

Random numbers can be obtained in the range you specify by using random;

Random rd=new random (); int i=rd. Next ();//generates a non-negative integer int j=rd. Next (10);//generates integer int k=rd within 0-9. Next (10,100);//number int m=rd within 10=100. Nextdouble ();//Generate a real type of random number "0,1" within


Note: In the case of high concurrency, the random number may be the same, can be solved by thread sleep ();


This article is from the "World is the same" blog, please be sure to keep this source http://970076933.blog.51cto.com/9767314/1887865

C # get random number (randomness class)

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.