我定义了以下枚举(我已用示例替换了实际细节):
Public Enum IceCream
<Description("")> Uninitialized
<Description("ChocolateChunk")> ChocolateChunk
<Description("MintOreo")> MintOreo
End Enum
我有一个我想要调用的函数:
Public Overloads Sub SetFood(ByVal food As String, ByRef NewVal As [Enum], ByRef OldVal As [Enum])
OldVal = NewVal
End Sub
以下是我用来尝试调用SetFood的代码:
Public Property IceCreamEnum() As Enumerations.IceCream
Get
Return _IceCreamEnum
End Get
Set(ByVal Value As Enumerations.IceCream)
If Value <> _IceCreamEnum Then
SetFood("IceCreamEnum", Value, _IceCreamEnum)
End If
End Set
End Property
我收到此错误:
Overload resolution failed because no accessible SetFood can be called without a narrowing conversion
我认为错误是因为我已经定义了IceCreamEnum并且它无法将其转换为System.Enum,但我无法弄清楚如何更正它以便我可以动态调用此SetFood函数我定义了不同类型的枚举(例如IceCreamEnum,BurgerEnum等)。任何人都可以告诉我如何将IceCreamEnum转换为SystemEnum,以便我可以调用此函数吗?