title: How do I redirect debug output in C#?
body: <p>At the moment I write a lot of status messages out using the following:</p>
  
  <pre><code>Debug.Writeline("This is my status message");
  </code></pre>
  
  <p>I would like to be able to create a method that allows me to either output messages via <code>Debug</code> or redirect them to a textbox in my UI. However, the Debug and Textbox objects are not compatible. How can I do this in such a way that the caller can use the same message to generate output and let the calling method decide where to send it (i.e., to Debug, the UI, or even a log file)?</p>