我有以下的switch表达式:
public Size GetSize(string brand, string isGift) => (brand, isGift) switch
{
(brand: "1", isGift: "Y") => Size.Small,
(brand: "1", isGift: "N") => Size.Medium,
(brand: "2") => Size.Big, // in this line I get and error
_ => Size.NoSize
};
我知道如果品牌是“2”,则它将始终是Size.Big
,我想忽略此语句中的isGift
字符串,但我却得到了编译错误。有没有办法解决这个问题?