You can able to enumerate an enum to get it's values and names.
Example :
We have an emum Called "Sports".
You can enumerate this by Values and by Names.
Following code demostrate how you can enumerate by Values.
Example :
Following code demostrate how you can enumerate by Names.
Example :
Example :
We have an emum Called "Sports".
Public Enum Sports
Cricket
Hockey
Soccer
BaseBall
Tennis
End Enum
Cricket
Hockey
Soccer
BaseBall
Tennis
End Enum
You can enumerate this by Values and by Names.
Following code demostrate how you can enumerate by Values.
Example :
For Each strValue As String In [Enum].GetValues(GetType(Sports))
Response.Write(strValue.ToString())
Response.Write("</br>")
Next
Response.Write(strValue.ToString())
Response.Write("</br>")
Next
Following code demostrate how you can enumerate by Names.
Example :
For Each strName As Object In [Enum].GetNames(GetType(Sports))
Response.Write(strName.ToString())
Response.Write("</br>")
Next
Response.Write(strName.ToString())
Response.Write("</br>")
Next
No comments:
Post a Comment