Quick Enum Snippet. Get Values or Names based on Name or Value

16. October 2009

Read this article in your language IT | EN | DE | ES

Public Enum CCid
        A = 3
        D = 6
End Enum

'Get Name
Dim s As String = [Enum].GetName(GetType(CCid), 3)

'Get Value
Dim v As Integer = [Enum].Parse(GetType(CCid), "A")
However, I do it this way. Where I actually use the Enum Type and check to see if it exists first.
 

VB.NET, Code Snippets ,

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading