简体   繁体   中英

How do i generate a random integer with increment being only of 100's — C#

Random random = new Random();
int randomNumber = random.Next()

How do I set output random integers with increments being only in 100's?

您可以取0到9之间的一个随机数(假设您想要的数字介于100到900之间),然后将结果乘以100。

var num = random.Next(10) * 100;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM