title: What should I do when I am forced to write unreachable code?
body: <p>I have this simple piece of code:</p>
  
  <pre><code>public static int GetInt(int number)
  {
      int[] ints = new int[]{ 3, 7, 9, int.MaxValue };
      foreach (int i in ints)
          if (number &lt;= i)
              return i;
  
      return int.MaxValue; //this should be unreachable code since the last int is int.MaxValue and number &lt;= int.MaxValue is allways true so the above code will allways return
  }
  </code></pre>
  
  <p>The problem is that the compiler says that not every execution path returns a value. So I have to write code that will be never reached. My question is, what should I do in a situation like this? Should I return some default value or should I throw an exception. Also, if I want to throw an exception, what exception is suitable for throwing? I didn't find anything like <code>UnreachableCodeException</code>.</p>