title: How to strip out header from base 64 image in C#?
body: <p>I have following base 64 image:</p>
  
  <pre><code>var image='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0gA...';
  </code></pre>
  
  <p>I am using <code>Convert.FromBase64String()</code>to convert this to bytes:</p>
  
  <pre><code> byte[] bytes = Convert.FromBase64String(convert);
  </code></pre>
  
  <p>But before this, I need to strip out the header of Base 64 string (i.e <code>data:image/png;base64</code>). I am doing this using:</p>
  
  <pre><code>string convert = image.Replace("data:image/png;base64,", string.Empty);
  </code></pre>
  
  <p>I can write the same statement for all image extensions separately, but these images are very large and scanning through each one seems inefficient.</p>
  
  <p>I searched <a href="https://stackoverflow.com/questions/38633061/how-can-i-strip-the-dataimage-part-from-a-base64-string-of-any-image-type-in-ja?rq=1">this</a> solution which uses regular expression in PHP to cut off the header part, while <a href="https://stackoverflow.com/a/21302482/2828434">other</a> answer in PHP uses an inbuilt method <code>get_contents</code>.</p>
  
  <p>My Question is: Is there any inbuilt method to get only contents of base 64 url in C#? If not, then is there any generalized way to strip out header for all extensions?</p>