Generate Random Numbers in C#
www.tutorialsteacher.com › articles › generateAug 19, 2021 · Pass an array to fill the number of byte values. The following example shows how to generate a random number using NextBytes () method: Example: Generate Random Bytes. Random rnd = new Random(); byte[] randomBytes = new byte[4]; rnd.NextBytes(randomBytes); foreach (byte val in randomBytes) { Console.WriteLine(val); }