Today’s fun snippet, which I likely already knew and forgot:
If you want to see if a value is contained in your defined enum, this will do the trick.
if(Enum.IsDefined(typeof(yourEnum), someValue)) { // do stuff } else { // oh no, probably log an error or throw an exception // or show some validation message // your use case will vary }
msdn for reference