title: Why doesn't C# have lightweight exceptions?
body: <p>It's <a href="http://msdn.microsoft.com/en-us/library/ms229009%28VS.100%29.aspx" rel="noreferrer">often said</a> that you shouldn't use exceptions for regular error handling because of <a href="http://yoda.arachsys.com/csharp/exceptions2.html" rel="noreferrer">bad performance</a>.  My guess is that that bad performance is caused by having to instantiate a new exception object, generate a stack trace, etc.  So why not have lightweight exceptions?  Code like this is logically sound:</p>
  
  <pre><code>string ageDescription = "Five years old";
  try {
      int age = int.Parse(ageDescription);
  }
  catch (Exception) {
      // Couldn't parse age; handle parse failure
  }
  </code></pre>
  
  <p>And yet we're recommended to use <code>TryParse</code> instead to avoid the overhead of the exception.  But if the exception were just a static object that got initialized when the thread started, all the code throwing the exception would need to do is set an error code number and maybe an error string.  No stack trace, no new object instantiation.  It would be a "lightweight exception", and so the overhead for using exceptions would be greatly reduced.  Why don't we have such lightweight exceptions?</p>