title: C# String replace with dictionary
body: <p>I have a string on which I need to do some replacements. I have a <code>Dictionary&lt;string, string&gt;</code> where I have search-replace pairs defined. I have created following extension methods to perform this operation:</p>
  
  <pre><code>public static string Replace(this string str, Dictionary&lt;string, string&gt; dict)
  {
      StringBuilder sb = new StringBuilder(str);
  
      return sb.Replace(dict).ToString();
  }
  
  public static StringBuild Replace(this StringBuilder sb, 
      Dictionary&lt;string, string&gt; dict)
  {
      foreach (KeyValuePair&lt;string, string&gt; replacement in dict)
      {
          sb.Replace(replacement.Key, replacement.Value);
      }
  
      return sb;
  }
  </code></pre>
  
  <p>Is there a better way of doing that?</p>