System.FormatException:索引(从零开始)必须大于或等于零且小于参数列表的大小

System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list

Error : An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional info : Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

namespace Inheritance
{
    abstract class Airlines
    {
        public int Aid;
        protected string Aname, DOD, ToAdd, ToFrom, FromAdd;
        protected float Cost;
        public void Accept()
        {
            Console.WriteLine("Enter the Aid,Aname");
            Aid = Convert.ToInt32(Console.ReadLine());
            Aname = Console.ReadLine();
            Console.WriteLine("Enter DOD,ToAdd,FromAdd");
            DOD = Console.ReadLine();
            ToAdd = Console.ReadLine();
            FromAdd = Console.ReadLine();
            Console.WriteLine("Enter the  Cost");
            Cost = Convert.ToSingle(Console.ReadLine());
        }

        public abstract void DisplayInfo();
        public abstract void facility();
    }
    abstract class SpiceJet : Airlines
    {
        string PaymentMode;
        public void AcceptData()
        {
            //Console.WriteLine("Welcome");
            Accept();
        }

        public void payment()
        {
            Console.WriteLine("Enter The Payment Mode =");
            PaymentMode = Console.ReadLine();

        }
        public override void DisplayInfo()
        {
            Console.WriteLine("Aid id :{0},Aname is:{1},DOD is :{2},ToAdd is:{3},FromAdd is :{4},Cost is :{5},PaymentMode is :{6}", Aid, Aname, ToAdd, FromAdd, Cost, PaymentMode);

        }
        public abstract void typeclass();

    }
    class SpiceJetchild : SpiceJet
    {
        public override void facility()
        {

        }
        public override void typeclass()
        {

        }
    }
    class Program
    {
        static void Main(string[] args)
        {

            //Airlines a = new Airline();
            //SpiceJet sj = new SpiceJet();
            SpiceJetchild sj = new SpiceJetchild();
            sj.AcceptData();
            sj.payment();
            sj.DisplayInfo();
            sj.facility();
            sj.typeclass();
            Console.ReadKey();
        }
    }
}

这一行:

Console.WriteLine("Aid id :{0},Aname is:{1},DOD is :{2},ToAdd is:{3},FromAdd is :{4},Cost is :{5},PaymentMode is :{6}", Aid, Aname, ToAdd, FromAdd, Cost, PaymentMode);

您指定了 7 件商品,但您只提供了 6 件。