Here is a simple snippet of code that I always forget and have to look up time and time again.
This will check to see if a value (string or int) is a match for a enum. This can be useful when trying to load data from a database which is in key the form and you would like to represent that value as an enum.
In order to do this your enum has to have an implecit values defined for the enum.
The code below will not allow you to have consistant results and should not be used for this code.
Here is the code snippet to check for the enum as well as to cast it into the actual enum value.
As you can see, the code for this is pertty straight forward, but for some reason I always forget how to do it and have to relearn it every time.