Below is one of the ways to store/retrieve string data type using Enums .
This is particularly useful in situations where you have to deal with string values repeatedly in your project and don’t want to run into gotcha errors because you mistyped a string .
Imagine an Event logger where you log multiple error types (“connection error” ,”incorrect login details ”,”system error”).Its quite error prone to type those strings manually .So below is a sample of how you can do it in slightly better way
Public Class ErrorCode
Private Key As String
Public Shared ReadOnly SystemException As ErrorCode = New ErrorCode("201")
Public Shared ReadOnly DbAuthException As ErrorCode = New ErrorCode("202")
Private Sub New(key As String)
Me.Key = key
Public Overrides Function ToString() As String