lundi 13 mars 2023

How to generate random number from 0 to 122 using RandomNumberGenerator Class c#

byte[] rngBytes = new byte[4];
RandomNumberGenerator.Create().GetBytes(rngBytes);
int mynum= BitConverter.ToInt32(rngBytes, 0);

i have been getting bigger numbers from above code, which can be -ve or +ve numbers.

need help on how to generate random number from 0 to 100 using RandomNumberGenerator Class c#




Aucun commentaire:

Enregistrer un commentaire