How to enumerate through Enums in a Class

F

Faisal

Can anyone tell me if it is possible to enumerate through all the Enums within a class [and NOT the individual enumerations within a single Enum]. I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't seem to find an appropriate Reflection method to access Enums within a class

Thanks!
 
H

Herfried K. Wagner [MVP]

Faisal said:
Can anyone tell me if it is possible to enumerate through all the Enums
within a class

\\\
Dim atyp() As Type = GetType(Foo).GetNestedTypes()
For Each t As Type In atyp
If t.IsEnum Then
MsgBox(t.Name)
End If
Next t
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top