Is there a way to get c# compiler to emit an error if a switch(enum_val) is missing a case statement?
<p>I just realized I added a value to the list of "must-handle" values in my enum, but I didn't catch it until runtime. I know the C# compiler is really powerful when it comes to reflection and introspection of types, so I was wondering if there was a way to force a <code>switch</code>/<code>case</code> statement to cover all possible <code>enum</code> values?</p>

<p>Example:</p>

<pre><code>enum Colors
{
   Red,
   Blue,
   Green,
   Yellow
};

Colors c = ...;

switch (c)
{
   case Colors.Red:  // no error, Red is a Color
      break;
   case Colors.Blue:
   case Colors.Green:  // no error, Blue and Green handled as well
      break;
}  // whoops! "error: 'Colors.Yellow' unhandled"
   // or even, "error: no 'default' and 'Colors.Yellow' unhandled"
</code></pre>

<p>Edit: I guess I should have specified I wanted a compile-time solution.</p>
