title: BitConverter.ToString() vs Convert.ToBase64String()
body: <p>I had thought that <code>Convert.ToBase64String()</code> was the method to use to create a base64 string of a byte array, but I recently came across <code>BitConverter.ToString()</code>. What is the difference between the two?</p>
  
  <p>And more specifically when should one be used over the other?</p>
  
  <hr />
  
  <p>For example in <a href="https://stackoverflow.com/questions/2150455/how-do-i-create-an-md5-hash-digest-from-a-text-file-with-c">this question</a> about creating a MD5 digest, a comment by <a href="https://stackoverflow.com/users/226235/craigs">CraigS</a> on an answer states "ToBase64String doesn't return what I want. However, BitConverter.ToString around the byte array does the trick."</p>
  
  <pre><code>BitConverter.ToString(
      MD5.Create().ComputeHash(Encoding.Default.GetBytes(StringToEncode))
  ).Replace("-", "")
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>Convert.ToBase64String(
      MD5.Create().ComputeHash(Encoding.Default.GetBytes(StringToEncode))
  )
  </code></pre>
  
  <hr />
  
  <p>Also, what should be used to encode images to base64?</p>
  
  <pre><code>public string ImageToBase64(int Img_ID)
  {
      byte[] tempBytes = showImageById(Img_ID); // get image from DB
      return Convert.ToBase64String(tempBytes);
  }
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>public string ImageToBase64(int Img_ID)
  {
      byte[] tempBytes = showImageById(Img_ID); // get image from DB
      return BitConverter.ToString(tempBytes).Replace("-", "");
  }
  </code></pre>