Generate and display 5 random integers.
using System;
using System.Threading;
public class MainClass
{
public static void Main(){
Random rand = new Random();
byte[] bytes = new byte[4];
rand.NextBytes(bytes);
Console.WriteLine("Five random byte values:");
foreach (byte byteValue in bytes)
Console.Write("{0, 5}", byteValue);
Console.WriteLine("Five random integer values:");
for (int ctr = 0; ctr <= 4; ctr++)
Console.Write("{0,15:N0}", rand.Next());
}
}
Related examples in the same category