title: How to imitate string.Format() in my own method?
body: <p>I have an object with a custom <code>WriteLine(string)</code> method. Something like this:</p>
  
  <pre><code>public void WriteLine(string text)
  {
      this.StringList.Add(text);
  }
  </code></pre>
  
  <p>What is the easiest way to duplicate the functionality of <code>string.Format()</code> with this method? For example: What I currently often find myself doing is this:</p>
  
  <pre><code>myObj.WriteLine(string.Format("Hello, {0}", name));
  </code></pre>
  
  <p>If you create a new Console application their version of a <code>WriteLine()</code> method does exactly what I would prefer to do:</p>
  
  <pre><code>Console.WriteLine("Hello, {0}", name);
  </code></pre>
  
  <p>They eliminate the need to call <code>string.Format()</code>. Is it easy to make your method accept this somehow? Or am I going to have to create a thousand method overloads? Something like this:</p>
  
  <pre><code>public void WriteLine() { ... }
  
  public void WriteLine(string text) { ... }
  
  public void WriteLine(string text, object arg0) { ... }
  
  public void WriteLine(string text, object arg0, object arg1) { ... }
  
  public void WriteLine(string text, object arg0, object arg1, object arg2)
  {
      this.StringList.Add(string.Format(text, arg0, arg1, arg2));
  }
  
  // etc etc etc
  </code></pre>
  
  <p>Is that the only logical way to do this? Any suggestions are welcomed :)</p>