我正在为我的课程编写程序,并且我一直收到此错误:
System.FormatException(从零开始)必须大于或等于零且小于参数列表的大小。
// Read output to user
Console.WriteLine(" Packing Slip ");
Console.WriteLine("----------------------------------------");
Console.WriteLine(totalRoomArea + "{0,-30}{1,10:C}", " ft. Wall Area :");
Console.WriteLine(ceilingArea + "{0,-30}{1,10:C}", "ft. Ceiling Area :");
Console.WriteLine(amountOfPaintRequired + "{0,-30}{1,10:C}","gallon(s) " + paintTypeChoice + " " + "@" + paintPrice + " =" + paintFinalPrice );
Console.WriteLine(amountOfFlooringRequired + "{0,-30}{1,10:C}", "ft." + flooringTypeChoice + " " + "@" + flooringPrice + " =" + flooringFinalPrice);
Console.WriteLine(amountOfCasing + "{0,-30}{1,10:C}", "ft. of casing" + " " + "@" + casingPrice + "=" + casingFinalPrice);
Console.WriteLine(amountOfBaseboardRequired + "{0,-30}{1,10:C}", "ft. of baseboard" + " " + baseboardPrice + "=" + baseboardFinalPrice);
Console.WriteLine("============================================================================================================");
Console.WriteLine("{0,-30}{1,10:C}", "Net Total" + " " + "=" + netTotal);
Console.WriteLine("{0,-30}{1,10:C}", "GST" + " " + "=" + gst);
Console.WriteLine("----------------------------------------");
Console.WriteLine("{0,-30}{1,10:C}", "Total" + " " + "=" + total);
Console.WriteLine(" Press any key to exit... ");
Console.ReadLine();
答案 0 :(得分:0)
您正在使用Console.WriteLine
中的字符串格式化程序,例如{0},但您没有为此传递任何参数。
你应该像
一样使用它们string.Format("Hello {0}", PersonName);