Random Class

Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness.

Note that this class is not purely random number generator. It is pseudo-random number generator, explained here:

A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG), is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers. The PRNG-generated sequence is not truly random, because it is completely determined by an initial value, called the PRNG's seed (which may include truly random values). Although sequences that are closer to truly random can be generated using hardware random number generators, pseudorandom number generators are important in practice for their speed in number generation and their reproducibility.

Password generator:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
        //Define a variable with random class.
            var rr = new Random();
            //your password will contain 15 characters.
            for (int ff = 0; ff < 15; ff++)
            {
            //since rr is defined as random class, it can now have parameters like next, 
            //nextbytes etc
            //in ascii code, from 33 till 127 are characters for numberic, special 
            //characters, capital letter alphabets and small letter alphabets.
            
                Console.Write((char)rr.Next(33,127));
            }
            Console.WriteLine();
        }
    }
}

Last updated