CSharp examples for System:Random
Generates a random integer. The value is simply within int range.
using System.Text; using System.Security.Cryptography; using System;//w w w . j av a 2s .co m public class Main{ /// <summary> /// Generates a random integer. The value is simply within int range. /// </summary> /// <returns></returns> public static int GeneratRandomInt() { var rnd = SeedRandom(); return rnd.Next(); } private static Random SeedRandom() { return new Random(Guid.NewGuid().GetHashCode()); } }