为什么这不起作用。以下是我的代码:
private static void FillCatalogue()
{
int intCatalogueNumber = 0;
arrMyShows = new Show[intCatalogueNumber];
Show newShow = new Show();
//arrMyShows[intCatalogueNumber] = newShow;
Console.Clear();
Console.Write("Title: ");
arrMyShows[intCatalogueNumber].Title = Console.ReadLine();
Console.Write("Year: ");
arrMyShows[intCatalogueNumber].Year = Convert.ToInt32(Console.ReadLine());
Console.Write("Lead Actor: ");
arrMyShows[intCatalogueNumber].LeadActor = Console.ReadLine();
Console.Write("Price: ");
arrMyShows[intCatalogueNumber].RentalPrice = Convert.ToDouble(Console.ReadLine());
//Console.Write("Does the show have Blu-Ray discs? (Y/N) ");
Console.WriteLine(arrMyShows[intCatalogueNumber].Title + " " + arrMyShows[intCatalogueNumber].Year + " " + arrMyShows[intCatalogueNumber].LeadActor);
答案 0 :(得分:2)
您的数组arrMyShows
的大小为0;当然这不会起作用。给它另一个值:
int intCatalogueNumber = 0;
int size = SOMETHING;
arrMyShows = new Show[size];