我想将Enum
转换为Dictionary(Of T, Integer)
。我可以获得Dictionary(Of String, Integer)
,但如何让密钥成为Enum
而不是String
?
CODE
Sub Main
Dim returnString As KeyValuePair(Of String, Integer)
Dim returnEnum As KeyValuePair(Of Type, Integer)
returnString = New KeyValuePair(Of String, Integer)([Enum].GetName(GetType(ResponseCode), 3), 3)
returnEnum = New KeyValuePair(Of Type, Integer)(GetType(ResponseCode), 3)
'Tesing with LinqPad
returnString.Dump()
returnEnum.Dump()
End Sub
Enum ResponseCode
Found = 1
Create = 2
Update = 3
End Enum
以下是使用LinqPad的输出
输出
returnString
KeyValuePair<String,Int32>
Update, 3
returnEnum
KeyValuePair<Type,Int32>
typeof(ResponseCode), 3