// Programmer: Janet Joy // Write a function to generate a random color using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace randomcolors { public partial class Form1 : Form { Random random = new Random(); // declare random just once public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.BackColor = RandomColor(); } Color RandomColor() { // Select random values for red, green and blue from 0 to 255. int red=random.Next(0, 256); int green = random.Next(0, 256); int blue = random.Next(0, 256); return Color.FromArgb(red, green, blue); } } }