我有一个程序,有一个超级车辆,并有3个类继承它汽车,卡车,小巴我需要采取类的实例,并显示它们在我的主窗体'FrmHire'上的列表框中我为此,有一个叫做舰队的班级。不能隐式转换类型
我不断收到此错误,
不能键入App1.Vehicle隐式转换为App1.Car。一个显式转换存在(是否缺少强制转换?)
private void lstFleet_SelectedIndexChanged(object sender, EventArgs e)
{
/*
* This method is used to control the list box
* It is called when a row is selected by the user, it then displays frmCar
* with the car details
*/
if (lstFleet.SelectedIndex > -1)
{
int index = lstFleet.SelectedIndex;
Car myCar = myFleet.fleet.ElementAt(index);
FrmCar carGui = new FrmCar();
carGui.car = myCar;
carGui.Show();
}
}
你可以指向抛出一个错误的行? – 2014-12-17 20:19:14