在VB.NET中,我循环遍历枚举名称列表(来自SQL表),以获取每个枚举对象的值。例如,
enumerations.colors,
enumerations.sizes,
enumerations.patterns,
enumerations.unitOfMeasure,
等
Private Sub DoEnums()
Dim dt As DataTable = sqltodt("Select * from enums")
For i As Integer = 0 To dt.Rows.Count - 1
Dim enumName As String = "enumerations." & dt.Rows(i).Item("enumName")
Dim dte As DataTable = EnumToTable(Type.GetType(enumName))
'do work here
Next i
End Sub
我希望Type.GetType(enumName)
返回枚举对象(即enumerations.color),但它不返回任何内容。
那么如何传递枚举名称并获取枚举对象?