CSharp examples for System:Random
Create a random boolean.
using System.Text; using System.Security.Cryptography; using System;//from w w w . j a v a2 s . c o m public class Main{ /// <summary> /// Create a random boolean. /// </summary> /// <returns>random boolean</returns> public static bool GenerateRandomBoolean() { // Create a byte array as a data source var rnd = SeedRandom(); return rnd.Next(0, 2) == 0; } private static Random SeedRandom() { return new Random(Guid.NewGuid().GetHashCode()); } }