我想实现以下功能:当用户从下拉列表中选择一部电影并单击“添加到购物车”按钮时,该电影将添加到下面的列表框中。
protected void addImageButton_Click(object sender, ImageClickEventArgs e)
{
string[] moviesArrayString = new string[10];
moviesArrayString[1] = "Badboy 2";
moviesArrayString[2] = "BadBoy 3";
moviesArrayString[3] = "The Godfather";
moviesArrayString[4] = "Inception";
moviesArrayString[5] = "The Shawshank Redemtion";
moviesArrayString[6] = "Star Wars";
moviesArrayString[7] = "The Metrix";
moviesArrayString[8] = "King Kong";
moviesArrayString[9] = "Point Break";
moviesArrayString[10] = "Top Gun";
cartListBox.Items.AddRange(moviesArrayString);
}
它给了我一些错误,我不知道该怎么做?错误是索引超出了数组的范围?