// Programmer: Janet Joy // Use timer to cycle through colors in an array //To do: add another color, change the speed 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 ColorChange { public partial class Form1 : Form { string[] myColors = { "red", "white", "blue","green" }; Color[] colors = { Color.Red, Color.White, Color.Blue,Color.Green }; int position = 0; public Form1() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { this.BackColor = colors[position]; this.Text = myColors[position]; // Add 1, but go back to 0 it the position is out of bounds position++; if (position >= colors.Length) position = 0; } } }