title: Unhandled Exception in List Sort
body: <p>So, I have a list containing a custom class, <strong>MyClass</strong> <br/>
  <strong>MyClass</strong> has properties, which can be null (but aren't meant to be). <br/><br/>
  When this class is sorted, using a custom sorter, where the sorter accesses this null property and throws an exception, the exception is considered unhandled, even though there is a try-catch block around the sort method.<br/><br/>
  Now for some reason the exception still gets written to the console, which is what the exception handler is doing.<br/><br />
  I have a real application with this same issue, causing my unit tests to fail, even though the exception is handled correctly and I cannot explain this.<br/></p>
  
  <p>So I have attached some sample code to explain myself better, run this from VS. <br /> 
  <br />
  Updated Code<br />
  <strong>Results:</strong><br/>
  <em>System.InvalidOperationException<br />
  Failed to compare two elements in the array.<br/>
  Done!</em><br />
  So it seems to be handling my <em>custom</em> exception, and throwing its own?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  
  namespace TestSortException
  {
      class Program
      {
          static void Main()
          {
              try
              {
                  var list = new List&lt;MyClass&gt;
                                           {
                                               new MyClass("1"),
                                               new MyClass(null),
                                               new MyClass("fdsfsdf")
                                           };
  
  
  
                  list.Sort(new MyClassSorter());
              }
              catch(Exception e)
              {
                  Console.WriteLine(e.GetType());
                  Console.WriteLine(e.Message);
              }
  
              Console.WriteLine("Done!");
              Console.ReadLine();
  
          }
      }
  
      class MyClassSorter : IComparer&lt;MyClass&gt;
      {
          public int Compare(MyClass x, MyClass y)
          {
  //            try
  //            {
                  if (x.MyString == y.MyString)
                      return 0;
                  // Unhandled??? Exception here
                  if (x.MyString.Length &gt; y.MyString.Length)
                      return 1;
  
                  return -1;
  //            }
  //            catch (Exception)
  //            {
  //                return -1;
  //            }
          }
      }
  
      class MyClass
      {
          private string _myString;
  
          public string MyString
          {
              get
              {
                  if (_myString == null) throw new DataException("MyString is Null");
                  return _myString;
              }
          }
  
          public MyClass(string myString)
          {
              _myString = myString;
          }
  
      }
  
  }
  </code></pre>