gpt4 book ai didi

c# - 系统格式异常 : Index (zero based) must be greater than or equal to zero and less than the size of the argument list

转载 作者:行者123 更新时间:2023-12-01 22:24:37 30 4
gpt4 key购买 nike

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 个。

关于c# - 系统格式异常 : Index (zero based) must be greater than or equal to zero and less than the size of the argument list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36050489/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com