【发布时间】:2014-09-27 08:37:18
【问题描述】:
public enum VehicleData
{
Dodge = 15001,
BMW = 15002,
Toyota = 15003
}
我想在字符串数组中获取高于 15001、15002、15003 的值,如下所示:
string[] arr = { "15001", "15002", "15003" };
我尝试了下面的命令,但它给了我名称而不是值的数组。
string[] aaa = (string[]) Enum.GetNames(typeof(VehicleData));
我也试过string[] aaa = (string[]) Enum.GetValues(typeof(VehicleData));,但也没有用。
有什么建议吗?
【问题讨论】:
-
如果您更喜欢更通用的实现,You can find it here。