Link to home
Start Free TrialLog in
Avatar of lbargers
lbargers

asked on

How to iterate through enumeration in VB.net

Hi,
I would like to iterate through an enumeration and capture the names and coresponding values. The problem I am running into, is when I attempt to capture the enumeration type using the following line:

Dim mytype As Type = Type.GetType("Bold.Providers.CRMDataProvider.CaseViews")

the type is "Nothing". Am I not correctly qualifying the namespace where my enumeration exists?


Dim mytype As Type = Type.GetType("Providers.CRMDataProvider.CaseViews")
            Dim names() As String = [Enum].GetNames(Type.GetType("Bold.Providers.CRMDataProvider.CaseViews"))
            Dim vals As Array = [Enum].GetValues(Type.GetType("Bold.Providers.CRMDataProvider.CaseViews"))
 
            For Each Name As String In names
                Debug.Print(Name)
            Next
 
            For Each value As Object In vals
                Debug.Print(value)
            Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial