我想获得枚举的基础类型的字符串表示。
Dim target As System.ConsoleColor = ConsoleColor.Cyan
Dim actual = 'What goes here?
Dim expected = "11"
答案 0 :(得分:2)
用C#术语;你可以假设int:
int val = (int) target;
string valString = val.ToString();
或者如果你不想要这个假设:
object val = Convert.ChangeType(target,
Enum.GetUnderlyingType(typeof(ConsoleColor)));
string valString = val.ToString();