Random Number Generating in C#

RANDOM NUMBER GENERATE

Random 

using System;

using System.Windows.Forms;

 

namespace WindowsProject

{

    public partial class RandomNum : Form

    {

        private void button1_Click(object sender, EventArgs e)

        {

            timer1.Start();

        }

        private void timer1_Tick(object sender, EventArgs e)

        {

            string allowedChars = "";

            // allowedChars += "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,";

            allowedChars += "1,2,3,4,5,A,B,C,D,E";

            char[] sep = { ',' };

            string[] arr = allowedChars.Split(sep);

            string passwordString = "";

            string temp = "";

            Random rand = new Random();

            for (int i = 0; i < 8; i++)

            {

                temp = arr[rand.Next(0, arr.Length)];

                passwordString += temp;

            }

            textBox1.Text = passwordString;

        }

    }

}

Next Recommended Reading Unique Random Number Generation in C#