Generates a random integer. The value is simply within int range. - CSharp System

CSharp examples for System:Random

Description

Generates a random integer. The value is simply within int range.

Demo Code


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());
        }
}

Related Tutorials