如何使用枚举名称获取枚举类型? [英] How to get Enum type using Enum name?

查看:89
本文介绍了如何使用枚举名称获取枚举类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何仅使用Enum名称获取Enum的类型?


例如


Dim enumType as System.Type

Dim enumName as String =" MyEnum"


enumType = ???(enumName)

我试过了使用Type.GetType(enumName)按名称检索Enum的类型,

但我总是得到值Nothing作为回报。


- Don

How do I get an Enum''s type using only the Enum name?

e.g.

Dim enumType as System.Type
Dim enumName as String = "MyEnum"

enumType = ???(enumName)
I''ve tried using Type.GetType(enumName) to retrieve an Enum''s type by name,
but I always get the value Nothing in return.

- Don

推荐答案

不确定我跟着,不要...


所有枚举只有整数/数字成员。也许你的意思是

else?

" Don" <未***** @ oblivion.com>在消息中写道

新闻:EaD4e.904575
not sure i follow, don...

all enums only have integer/numeric members. perhaps you mean something
else?
"Don" <un*****@oblivion.com> wrote in message
news:EaD4e.904575


Xk.345025@pd7tw3no ...

|如何仅使用Enum名称获得Enum的类型?

|

|例如

|

| Dim enumType as System.Type

| Dim enumName as String =" MyEnum"

|

| enumType = ???(enumName)

|

|

|我已经尝试使用Type.GetType(enumName)来检索Enum'的类型

名称,

|但我总是得到没有价值的回报。

|

| - Don

|

|
Xk.345025@pd7tw3no...
| How do I get an Enum''s type using only the Enum name?
|
| e.g.
|
| Dim enumType as System.Type
| Dim enumName as String = "MyEnum"
|
| enumType = ???(enumName)
|
|
| I''ve tried using Type.GetType(enumName) to retrieve an Enum''s type by
name,
| but I always get the value Nothing in return.
|
| - Don
|
|





我不喜欢不知道Enum的可能值与

获得Enum的Type对象有什么关系。

" steve" < a@b.com>在留言新闻中写道:Mo **************** @ fe04.lga ...
?

I don''t understand what the possible values of an Enum has to do with
getting a Type object for an Enum.
"steve" <a@b.com> wrote in message news:Mo****************@fe04.lga...
不确定我跟着,不要......

所有枚举只有整数/数字成员。也许你的意思是
其他?

" Don" <未***** @ oblivion.com>在消息中写道
新闻:EaD4e.904575
not sure i follow, don...

all enums only have integer/numeric members. perhaps you mean something
else?
"Don" <un*****@oblivion.com> wrote in message
news:EaD4e.904575


这篇关于如何使用枚举名称获取枚举类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆