c# random color

47

c# random color -

Random r = new Random();
BackColor = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), 0);

c# random color -

public partial class Form1 : Form
{
    private Random rnd = new Random();

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {  
        Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));

        BackColor = randomColor;
    }
}

Comments

Submit
0 Comments