title: .Net equivalent to Java's AssertionError
body: <p>In Java, I will occasionally throw an <a href="http://java.sun.com/javase/6/docs/api/java/lang/AssertionError.html" rel="noreferrer"><code>AssertionError</code></a> directly, to assert that a particular line will not be reached.  An example of this would be to assert that the <code>default</code> case in a <code>switch</code> statement cannot be reached (see <a href="http://www.javaspecialists.eu/archive/Issue162.html" rel="noreferrer">this JavaSpecialists page</a> for an example).</p>
  
  <p>I would like to use a similar mechanism in .Net. Is there an equivalent exception that I could use? Or is there another method that could be used with the same effect?</p>
  
  <p><strong>Edit</strong> - To clarify, I'm looking for a mechanism to flag failures at runtime, in released code, to indicate that there has been a (possibly catastrophic) failure of some invariant in the code.  The linked example generates a random integer between 0 and 2 (inclusive) and asserts that the generated number is always 0, 1 or 2.  If this assertion doesn't hold, it would be better to stop execution completely rather than continue with some unknown corrupt state of the system.</p>