By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

How to enumerate through Enums in a Class

P: n/a
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!

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Faisal" <faisal.ibrahim@-NOSPAM-dfait-maeci.gc.ca> schrieb:
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
///

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

Nov 21 '05 #2

P: n/a
"Faisal" <faisal.ibrahim@-NOSPAM-dfait-maeci.gc.ca> schrieb:
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
///

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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.