Start a new applicatation and add a combo box. Name it cboColor and write the code as shown below:
// Programmer: Janet Joy
// Working with arrays
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 colors
{
public partial class Form1 : Form
{
string[] myColors = { "red", "yellow", "blue", "white" };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Add each color to the combo box
for(int i=0;i<myColors.Length;i++)
{
cboColor.Items.Add(myColors[i]);
}
// Make the first color (red) be selected.
cboColor.SelectedIndex = 0;
}
}
}