每次运行程序时,我都会收到system.formatexception错误,并且在最后一个分号上用红色下划线突出显示此部分。对于它为什么要这样做以及如何解决这种情况有任何想法?
output1.Text = "Supplies" + "\n" +
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "Underlay ", underlay, " panels", underlaycost.ToString("C2"))) + "\n" +
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "Screws ", screws, " boxes", screwscost.ToString("C2"))) + "\n" +
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "Adhesive ", gallonsofadhesive, " gallons", adhesivecost.ToString("C2"))) + "\n" +
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "Grout ", bagsofgrout, " bags", groutcost.ToString("C2"))) + "\n" +
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "tile " + "Pallets ", pallet, palletcost.ToString("C2"))) + "\n" +
(string.Format("{0,20} | {1,-23} | {2,40}", "Packs ", packs, packcost.ToString("C2"))) + "\n" +
(string.Format("{0,20} | {1,-23} | {2,40}", "Tiles ", tiles, individualtilescost.ToString("C2"))) + "\n" +
(string.Format("{0,20} | {1,-23} | {2,40}", "Thresholds", threshold, thresholdscost.ToString("C2")));
答案 0 :(得分:3)
在这一行:
(string.Format("{0,-10} | {1,20} | {2,-23} | {3,40}", "tile " + "Pallets ", pallet, palletcost.ToString("C2"))) + "\n" +
您正在寻找4个参数,但只传递了3个参数:
"tile " + "Pallets ",
pallet,
palletcost.ToString("C2")