title: Custom Ternary-esque Operator for Enumerations with Custom Compiler
body: <p>I recently found my self wondering if there was an existing operator similar to the Ternary Operator, but for enumerations....  This could be a handle tool for writing less code for processing the value of an enumeration...  </p>
  
  <p>I was unable to find anything, so I pose the question...  </p>
  
  <p>How can I build my own operator for handling enumerations as outlined below?</p>
  
  <p>Take the following enumeration:</p>
  
  <pre><code>public enum ComTypes { Call, Email, SMS } 
  </code></pre>
  
  <p>Lets say I need to assign a title of a popup dialog based on the ComType.  Currently I could use Ternary operator like so:</p>
  
  <pre><code>ComTypes comType = ...;
  var title = comType == ComTypes.Call ? "Make a Call" : 
      comType == ComTypes.Email ? "Send an Email" : 
      /* ComTypes.SMS */ "Send a Text";
  </code></pre>
  
  <p>What i would like is to get a cleaner more concise format with a new operator for enumerations...  Something like the following:</p>
  
  <pre><code>ComTypes comType = ...;
  var title = comType ? 
      .Call: "Make a Call", 
      .Email: "Send an Email", 
      .SMS|default: "Send a Text";
  </code></pre>
  
  <p>So I guess my starter questions are:</p>
  
  <ol>
  <li>Can I create a custom operator and use it in parallel with normal C# compiler?</li>
  <li>Assuming I can create the operator, can I use the "?" as the operator for enumerations even though it is being used by the standard Ternary Op for Boolean values?</li>
  <li>I know I can go to Google for this one, but if anyone has any recommendations on good compiler creation articles that would be great.</li>
  </ol>
  
  <p><strong>--EDIT--</strong></p>
  
  <p>I just want to get this up here... I know that it wouldn't be practical if this were stopping me from doing development...  I know how to achieve this several other ways...  What i want here is some help understanding my starting points for achieving what I have outlined...  Merely for the pleasure of trying to code it out and learn more about the framework I use from day to day.</p>