Returns the given number of seed bytes generated for the first running of a new instance of the random number generator. - CSharp System

CSharp examples for System:Random

Description

Returns the given number of seed bytes generated for the first running of a new instance of the random number generator.

Demo Code


using System;/*w  w w.  j av a2s .co  m*/

public class Main{
        /// <summary>
         /// Returns the given number of seed bytes generated for the first running of a new instance 
         /// of the random number generator.
         /// </summary>
         /// <param name="numberOfBytes">Number of seed bytes to generate.</param>
         /// <returns>Seed bytes generated</returns>
         public static byte[] GetSeed(int numberOfBytes)
         {
            System.Security.Cryptography.RNGCryptoServiceProvider generatedSeed = new System.Security.Cryptography.RNGCryptoServiceProvider();
            byte[] seeds = new byte[numberOfBytes];
            generatedSeed.GetBytes(seeds);
            return seeds;
         }
}

Related Tutorials