How to generate random numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to generate random numbers?

It doesn't matter what language to use, but i prefer c#. i don't want to use the Random class because it generates pseudo-random numbers. It means each time it will return the same results. How to actually generate completely random numbers? Thank you

1st Sep 2017, 3:49 PM
Damon Keane
2 Answers
+ 1
It really depends on the context, Random class is good enough for non-security application like producing uncertainties in game. If you're concern about security, you may take a look on the RNGCryptoServiceProvider class (C#) to generate cryptographically-strong random bytes. P/S: It's equivalent to SecureRandom class in Java.
2nd Sep 2017, 2:56 AM
Zephyr Koo
Zephyr Koo - avatar