Barry R. and Rob P.'s coworker had a problem: how could he really, really make sure they verify that a value stored in an enumeration, say the EmailsFormat enum, is actually a valid value for that enumeration? With the handy FromEmailsFormat function of course!
public enum EmailsFormat { HTML, Text } ... public static EmailFormat FromEmailsFormat( EmailsFormat emailsFormat ) { switch ( emailsFormat ) { case EmailsFormat.HTML: return EmailFormat.HTML; case EmailsFormat.Text: return EmailFormat.Text; default: throw new Exception( "Unknown EmailsFormat enum value!" ); } }
