title: A design for a Foo/TryFoo method pair that has the best performance?
body: <p>I have the common scenario of needing to write a pair of methods:</p>
  
  <ul>
  <li>One that gets a result and throws an exception if it fails, and</li>
  <li>a <code>Try</code>-variant of the same method that attempts to get the result as an <code>out</code> param, and returns a <code>bool</code> that indicates success status.</li>
  </ul>
  
  <p>Here are two examples that illustrate the two approaches that I am considering. Which of these approaches provides the best performance? Also, is one approach likely to be easier to maintain than the other? I am also open to suggestions for other ways to implement this pair of methods.</p>
  
  <p>Method 1: <code>Foo()</code> as master</p>
  
  <pre><code>public string GetAnswer(string question) {
  
      string answer = null;
  
      if(!this.TryGetAnswer(question, out answer)) {
          throw new AnswerNotFoundException();
      }
  
      return answer;
  }
  
  public bool TryGetAnswer(string question, out string answer) {
  
      answer = null;
  
      //business logic
  
      return answer != null;
  }
  </code></pre>
  
  <p>Method 2: <code>TryFoo()</code> as master</p>
  
  <pre><code>public string GetAnswer(string question) {
  
      //business logic
  
      if(!answerFound) {
          throw new AnswerNotFoundException();
      }
      return answer;
  }
  
  public bool TryGetAnswer(string question, out string answer) {
  
      try {
          answer = this.GetAnswer(question);
          return true;
      } catch (AnswerNotFoundException e) {
          answer = null;
          return false;
      }
  }
  </code></pre>