无效的表达式项';字符串';

本文关键字:字符串 表达式 无效 | 更新日期: 2024-06-14 03:12:55

错误:

表达式术语"string"无效

施工单位:

public Car(string make, string model, int condition, double price, int passenger)
  :base(string make, model, condition, price)

无效的表达式项';字符串';

问题:base class构造函数发送参数时,不需要使用datatype
解决方案:base()参数make 中删除string

试试这个:

public Car(string make, string model, int condition, double price, int passenger )
           :base(make, model, condition, price)
public Car(string make, string model, int condition, double price, int passenger )
       :base(make, model, condition, price)

只需删除"字符串"-您像调用普通函数一样调用构造函数,因此不需要关键字字符串