473,375 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,375 software developers and data experts.

How to get Enum type using Enum name?

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
Nov 21 '05 #1
13 12346
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...
| 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
|
|
Nov 21 '05 #2
Don
?

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...
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...
| 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
|
|

Nov 21 '05 #3
"Don" <un*****@oblivion.com> schrieb:
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.

Make sure you fully qualify the type name correctly. You can determine a
type's full name by using 'GetType(<type name>).FullName'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
the quandry, of course, is that the type of object of an enum is...enum. the
possible values of the members of an enum were not what i commented on, but
the fact that the members themselves are all, and always, integer values.

hence, to me, you question is a bit vexing...an enum object is an enum type
and its members are integers.

could you be more specific is what it is you'd like to discover about an
enum?
"Don" <un*****@oblivion.com> wrote in message
news:osD4e.908411$6l.111545@pd7tw2no...
| ?
|
| 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...
| > 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...
| > | 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
| > |
| > |
| >
| >
|
|
Nov 21 '05 #5
lemme guess, you have an function/sub/property param that could be one of
many enum's and you're trying to decide, by name, which to use for
conversion/validation/action to preform?

is it that or something similar?
"Don" <un*****@oblivion.com> wrote in message
news:osD4e.908411$6l.111545@pd7tw2no...
| ?
|
| 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...
| > 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...
| > | 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
| > |
| > |
| >
| >
|
|
Nov 21 '05 #6
Don
When you create an Enum, you create a new Type. Any variable that is
declared as an Enum has that Enum as it's type. A variable is not of type
Integer when declared as an Enum you've created. The System.Type class even
has a property call IsEnum. I've written other code that retrieves all
nested types of a class, and Enums declared in the class are returned as
Types. I know you can get the Type of an Enum. I just can't seem to get it
to work when I'm just passing the name of the Enum to Type.GetType().

I am trying to determine all the members of an Enum, given only the Enum's
name. That is, I want to get the Enum's Type so I can use the
Enum.GetNames() or Enum.GetValues() method to retrieve a list of all of its
members. I don't know how else to put it.

"steve" <a@b.com> wrote in message news:hX*****************@fe07.lga...
the quandry, of course, is that the type of object of an enum is...enum. the possible values of the members of an enum were not what i commented on, but the fact that the members themselves are all, and always, integer values.

hence, to me, you question is a bit vexing...an enum object is an enum type and its members are integers.

could you be more specific is what it is you'd like to discover about an
enum?
"Don" <un*****@oblivion.com> wrote in message
news:osD4e.908411$6l.111545@pd7tw2no...
| ?
|
| 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...
| > 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...
| > | 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
| > |
| > |
| >
| >
|
|

Nov 21 '05 #7
Don
Hmmm... What you suggest works, but only if the Enum is declared in the same
project. If I try to do the same thing with an Enum declared in a
referenced dll, then the Type.GetType() method returns Nothing.

This is the code I am executing:

Public Enum abc
val1 = 1
val2 = 2
End Enum

Dim s As String
s = GetType(abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

This works fine. However, if, say, the "abc" Enum existed in a dll that I
was referencing, the code does not work:

' (assuming "abc" is a publicly declared Enum in a public module called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Fails!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"Don" <un*****@oblivion.com> schrieb:
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.

Make sure you fully qualify the type name correctly. You can determine a
type's full name by using 'GetType(<type name>).FullName'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8
Don
I just discovered that the following code works:

' (assuming "abc" is a publicly declared Enum in a public module called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).AssemblyQualifi edName '<--- NOT
FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

Thanks for pointing me into the right direction.

- Don
"Don" <un*****@oblivion.com> wrote in message
news:ZrR4e.914768$8l.831814@pd7tw1no...
Hmmm... What you suggest works, but only if the Enum is declared in the same project. If I try to do the same thing with an Enum declared in a
referenced dll, then the Type.GetType() method returns Nothing.

This is the code I am executing:

Public Enum abc
val1 = 1
val2 = 2
End Enum

Dim s As String
s = GetType(abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

This works fine. However, if, say, the "abc" Enum existed in a dll that I
was referencing, the code does not work:

' (assuming "abc" is a publicly declared Enum in a public module called ' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Fails!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"Don" <un*****@oblivion.com> schrieb:
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.

Make sure you fully qualify the type name correctly. You can determine a type's full name by using 'GetType(<type name>).FullName'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Nov 21 '05 #9
Don
Duh. I forgot that I will only have the name of the Enum as a string to
start with. It doesn't look like I'll be able to do this because the
AssembylQualifiedName -- which is what I need to start off with -- contains
version information which may change, so it cannot be hardcoded into my
project. Argh!
"Don" <un*****@oblivion.com> wrote in message
news:IAR4e.915774$6l.884013@pd7tw2no...
I just discovered that the following code works:

' (assuming "abc" is a publicly declared Enum in a public module called ' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).AssemblyQualifi edName '<--- NOT FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

Thanks for pointing me into the right direction.

- Don
"Don" <un*****@oblivion.com> wrote in message
news:ZrR4e.914768$8l.831814@pd7tw1no...
Hmmm... What you suggest works, but only if the Enum is declared in the same
project. If I try to do the same thing with an Enum declared in a
referenced dll, then the Type.GetType() method returns Nothing.

This is the code I am executing:

Public Enum abc
val1 = 1
val2 = 2
End Enum

Dim s As String
s = GetType(abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

This works fine. However, if, say, the "abc" Enum existed in a dll that I
was referencing, the code does not work:

' (assuming "abc" is a publicly declared Enum in a public module

called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Fails!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"Don" <un*****@oblivion.com> schrieb:
> 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.
Make sure you fully qualify the type name correctly. You can

determine a type's full name by using 'GetType(<type name>).FullName'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



Nov 21 '05 #10
Don
Success! To do what I want to do I will simply need to know one more thing:
the assembly the Enum is declared in. Here is a sample of code that works
(I am typing this in manually, so it's a little different from my executing
code):

' Known information about Enum
Dim assemblyName as String = "OtherDLL"
Dim enumName as String = "OtherDLL.Enumerations+abc" ' Note the "+"

Dim ax As System.Reflection.Assembly = _
System.Reflection.Assembly.Load(assemblyName)
Dim tx As Type = ax.GetType(enumName) ' <--- Works!

Now I can get what I am looking for using the following code:

Dim a1 As Array
a1 = [Enum].GetNames(tx)
- Don
"Don" <un*****@oblivion.com> wrote in message
news:IDR4e.914849$8l.462977@pd7tw1no...
Duh. I forgot that I will only have the name of the Enum as a string to
start with. It doesn't look like I'll be able to do this because the
AssembylQualifiedName -- which is what I need to start off with -- contains version information which may change, so it cannot be hardcoded into my
project. Argh!
"Don" <un*****@oblivion.com> wrote in message
news:IAR4e.915774$6l.884013@pd7tw2no...
I just discovered that the following code works:

' (assuming "abc" is a publicly declared Enum in a public module called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).AssemblyQualifi edName '<---

NOT
FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

Thanks for pointing me into the right direction.

- Don
"Don" <un*****@oblivion.com> wrote in message
news:ZrR4e.914768$8l.831814@pd7tw1no...
Hmmm... What you suggest works, but only if the Enum is declared in
the
same
project. If I try to do the same thing with an Enum declared in a
referenced dll, then the Type.GetType() method returns Nothing.

This is the code I am executing:

Public Enum abc
val1 = 1
val2 = 2
End Enum

Dim s As String
s = GetType(abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

This works fine. However, if, say, the "abc" Enum existed in a dll

that I was referencing, the code does not work:

' (assuming "abc" is a publicly declared Enum in a public module

called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).FullName

Dim t As Type
t = Type.GetType(s) ' <--- Fails!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
> "Don" <un*****@oblivion.com> schrieb:
> > 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.
>
>
> Make sure you fully qualify the type name correctly. You can

determine
a
> type's full name by using 'GetType(<type name>).FullName'.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>



Nov 21 '05 #11
Don
And an additional tip to those following in my footsteps: You can easily get
the assembly name from the full name of the Enum using the following bit of
code:

assemblyName = enumName.Substring(0, InStr(enumName, ".") - 1)

Use this and you don't need to separately store the assembly name.

- Don
"Don" <un*****@oblivion.com> wrote in message
news:0LR4e.911987$Xk.128619@pd7tw3no...
Success! To do what I want to do I will simply need to know one more thing: the assembly the Enum is declared in. Here is a sample of code that works
(I am typing this in manually, so it's a little different from my executing code):

' Known information about Enum
Dim assemblyName as String = "OtherDLL"
Dim enumName as String = "OtherDLL.Enumerations+abc" ' Note the "+"

Dim ax As System.Reflection.Assembly = _
System.Reflection.Assembly.Load(assemblyName)
Dim tx As Type = ax.GetType(enumName) ' <--- Works!

Now I can get what I am looking for using the following code:

Dim a1 As Array
a1 = [Enum].GetNames(tx)
- Don
"Don" <un*****@oblivion.com> wrote in message
news:IDR4e.914849$8l.462977@pd7tw1no...
Duh. I forgot that I will only have the name of the Enum as a string to
start with. It doesn't look like I'll be able to do this because the
AssembylQualifiedName -- which is what I need to start off with --

contains
version information which may change, so it cannot be hardcoded into my
project. Argh!
"Don" <un*****@oblivion.com> wrote in message
news:IAR4e.915774$6l.884013@pd7tw2no...
I just discovered that the following code works:

' (assuming "abc" is a publicly declared Enum in a public module

called
' "Enumerations" in the referenced class library "OtherDLL")
Dim s As String
s = GetType(OtherDLL.Enumerations.abc).AssemblyQualifi edName '<---
NOT
FullName

Dim t As Type
t = Type.GetType(s) ' <--- Works!

Thanks for pointing me into the right direction.

- Don
"Don" <un*****@oblivion.com> wrote in message
news:ZrR4e.914768$8l.831814@pd7tw1no...
> Hmmm... What you suggest works, but only if the Enum is declared in the same
> project. If I try to do the same thing with an Enum declared in a
> referenced dll, then the Type.GetType() method returns Nothing.
>
> This is the code I am executing:
>
> Public Enum abc
> val1 = 1
> val2 = 2
> End Enum
>
> Dim s As String
> s = GetType(abc).FullName
>
> Dim t As Type
> t = Type.GetType(s) ' <--- Works!
>
> This works fine. However, if, say, the "abc" Enum existed in a dll that
I
> was referencing, the code does not work:
>
> ' (assuming "abc" is a publicly declared Enum in a public module
called
> ' "Enumerations" in the referenced class library "OtherDLL")
> Dim s As String
> s = GetType(OtherDLL.Enumerations.abc).FullName
>
> Dim t As Type
> t = Type.GetType(s) ' <--- Fails!
>
>
> "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in

message > news:O6**************@tk2msftngp13.phx.gbl...
> > "Don" <un*****@oblivion.com> schrieb:
> > > 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.
> >
> >
> > Make sure you fully qualify the type name correctly. You can

determine
a
> > type's full name by using 'GetType(<type name>).FullName'.
> >
> > --
> > M S Herfried K. Wagner
> > M V P <URL:http://dotnet.mvps.org/>
> > V B <URL:http://classicvb.org/petition/>
> >
>
>



Nov 21 '05 #12
hmmm...

so you're saying that when you create an enum, you are actually creating an
object who's base class is enum? such that:

enum foo
bar = 0
end enum

dim e as foo
if typeof e is foo then return true

would not throw an error and neither would:

dim e as object = foo
if typeof e is enum then return true

both would return true...that about right? perhaps, i just haven't had need
to discover that nuance yet. i have seen in this ng code that does exactly
what you're wanting to do. have you googled yet?
"Don" <un*****@oblivion.com> wrote in message
news:qnR4e.915721$6l.12993@pd7tw2no...
| When you create an Enum, you create a new Type. Any variable that is
| declared as an Enum has that Enum as it's type. A variable is not of type
| Integer when declared as an Enum you've created. The System.Type class
even
| has a property call IsEnum. I've written other code that retrieves all
| nested types of a class, and Enums declared in the class are returned as
| Types. I know you can get the Type of an Enum. I just can't seem to get
it
| to work when I'm just passing the name of the Enum to Type.GetType().
|
| I am trying to determine all the members of an Enum, given only the Enum's
| name. That is, I want to get the Enum's Type so I can use the
| Enum.GetNames() or Enum.GetValues() method to retrieve a list of all of
its
| members. I don't know how else to put it.
|
|
|
| "steve" <a@b.com> wrote in message news:hX*****************@fe07.lga...
| > the quandry, of course, is that the type of object of an enum is...enum.
| the
| > possible values of the members of an enum were not what i commented on,
| but
| > the fact that the members themselves are all, and always, integer
values.
| >
| > hence, to me, you question is a bit vexing...an enum object is an enum
| type
| > and its members are integers.
| >
| > could you be more specific is what it is you'd like to discover about an
| > enum?
| >
| >
| > "Don" <un*****@oblivion.com> wrote in message
| > news:osD4e.908411$6l.111545@pd7tw2no...
| > | ?
| > |
| > | 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...
| > | > 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...
| > | > | 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
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Nov 21 '05 #13
Don
This is the solution to my problem (which I posted in a different branch of
my original thread):

' Known information about Enum
Dim assemblyName as String = "OtherDLL"
Dim enumName as String = "OtherDLL.Enumerations+abc"

Dim ax As System.Reflection.Assembly = _
System.Reflection.Assembly.Load(assemblyName)
Dim tx As Type = ax.GetType(enumName)

What's stored in the tx variable is the result I was seeking. I wanted to
get the type of an Enum using just a string containing the Enum's name.
This is how to do it (when the Enum is in a different assembly). It boils
down to this:

<Assembly>.GetType(<EnumNameAsString>)

- Don
"steve" <a@b.com> wrote in message news:KK************@fe05.lga...
hmmm...

so you're saying that when you create an enum, you are actually creating an object who's base class is enum? such that:

enum foo
bar = 0
end enum

dim e as foo
if typeof e is foo then return true

would not throw an error and neither would:

dim e as object = foo
if typeof e is enum then return true

both would return true...that about right? perhaps, i just haven't had need to discover that nuance yet. i have seen in this ng code that does exactly
what you're wanting to do. have you googled yet?
"Don" <un*****@oblivion.com> wrote in message
news:qnR4e.915721$6l.12993@pd7tw2no...
| When you create an Enum, you create a new Type. Any variable that is
| declared as an Enum has that Enum as it's type. A variable is not of type | Integer when declared as an Enum you've created. The System.Type class
even
| has a property call IsEnum. I've written other code that retrieves all
| nested types of a class, and Enums declared in the class are returned as
| Types. I know you can get the Type of an Enum. I just can't seem to get it
| to work when I'm just passing the name of the Enum to Type.GetType().
|
| I am trying to determine all the members of an Enum, given only the Enum's | name. That is, I want to get the Enum's Type so I can use the
| Enum.GetNames() or Enum.GetValues() method to retrieve a list of all of
its
| members. I don't know how else to put it.
|
|
|
| "steve" <a@b.com> wrote in message news:hX*****************@fe07.lga...
| > the quandry, of course, is that the type of object of an enum is...enum. | the
| > possible values of the members of an enum were not what i commented on, | but
| > the fact that the members themselves are all, and always, integer
values.
| >
| > hence, to me, you question is a bit vexing...an enum object is an enum
| type
| > and its members are integers.
| >
| > could you be more specific is what it is you'd like to discover about an | > enum?
| >
| >
| > "Don" <un*****@oblivion.com> wrote in message
| > news:osD4e.908411$6l.111545@pd7tw2no...
| > | ?
| > |
| > | 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... | > | > 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...
| > | > | 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
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|

Nov 21 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
6
by: James Brown | last post by:
Hi, I have the following enum declared: enum TOKEN { TOK_ID = 1000, TOK_NUMBER, TOK_STRING, /*lots more here*/ }; What I am trying to do is _also_ represent ASCII values 0-127 as TOKENs...
4
by: Chris | last post by:
I've lurked around long enough... Time to interract =) I'm trying to make sense of the following. I can't quite wrap my head around what this is actually doing: ------------- typedef enum {...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
9
by: Lawrence Oluyede | last post by:
I have a list of strings and i'd like to build up an enum from them... is there a way to do that? Thanks in advance. -- Lawrence "Rhymes" Oluyede http://loluyede.blogspot.com
5
by: Barry | last post by:
Hello, In VS2003, I tried using an enum and setting it into a field in a datarow. It seems as if the datatype of the field in the row determined what went into the field. If the datatype was...
1
by: Powers | last post by:
I currently have a large number of enums implemented into my Web Service. I am reworking the XML serialization of these enums. At present, each enum has hardcoded values, for example: xAttrs...
13
by: toton | last post by:
Hi, I have some enum (enumeration ) defined in some namespace, not inside class. How to use the enum constant's in some other namespace without using the whole namespace. To say in little...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.