我有一个带有 2 个可选参数的方法。
public IList<Computer> GetComputers(Brand? brand = null, int? ramSizeInGB = null)
{
return new IList<Computer>();
}
我现在正在尝试在我不想指定Brand
参数的其他地方使用此方法,而只是int
使用此代码时出现错误:
_order.GetComputers(ram);
我收到的错误:
Error 1 The best overloaded method match for 'ComputerWarehouse.Order.GetComputers(ComputerWarehouse.Brand?, int?)' has some invalid arguments C:\Users\avmin!\Documents\InnerWorkings Content\630dd6cf-c1a2-430a-ae2d-2bfd995881e7\content\T0062A2-CS\task\ComputerWarehouse\ComputerStore.cs 108 59 ComputerWarehouse
Error 2 Argument 1: cannot convert from 'int?' to 'ComputerWarehouse.Brand?' C:\Users\avmin!\Documents\InnerWorkings Content\630dd6cf-c1a2-430a-ae2d-2bfd995881e7\content\T0062A2-CS\task\ComputerWarehouse\ComputerStore.cs 108 79 ComputerWarehouse