title: How do I create my own custom ToString() format?
body: <p>I would like to specify the format of the <code>ToString</code> format, but I am not sure of the best way to handle this.</p>
  
  <p>For example if I have the following specifiers</p>
  
  <ul>
  <li>EE = equipment</li>
  <li>ED = equipment description</li>
  <li>EI = equipment ID</li>
  </ul>
  
  <p>so that if I used the <code>ToString</code> as such:</p>
  
  <pre><code>eqp.ToString("EE-EI (ED)")
  </code></pre>
  
  <p>the output might be:</p>
  
  <pre><code>"CAT994-61 (Front end loader)"
  </code></pre>
  
  <p>Would the best way be to search for the substrings and do a token replacement?
   Does any one have an example of doing this?</p>
  
  <p>I'm currently doing sequential <code>string.Replace</code>, which works nicely.</p>
  
  <pre><code>public class Equipment
  {
      // (other class code)
  
      public string ToString(string format)
      {
          string output = format;
          output = output.Replace("EE", _EquipID);
          output = output.Replace("ED", _EquipDescription);
          output = output.Replace("DI", _DepartID);
          return output;
      }
  
      public override string ToString()
      {
          return _EquipID;
      }
  }
  </code></pre>