title: how to make sure that an array of bytes is encoded by Base64?
body: <p>I have a method as below:</p>
  
  <pre><code>public void AddAttachment(byte[] attachment)
  {
  // how to make sure that the attachemnt is encoded by Base64?
  }
  </code></pre>
  
  <p>how to make sure the AddAttachment method accepts an array of bytes that is encoded with Base64?</p>
  
  <p>For example the below is a valid input before being sent to this method:</p>
  
  <pre><code>string attachmentInString = "Hello test";
  byte[] attachmentInBytes = System.Convert.FromBase64String(attachmentInString);
  </code></pre>
  
  <p>but if the attachmentInBytes was encoded using ASCII or etc, the AddAttachement method should throw an exception.</p>
  
  <p>How to achieve this?</p>
  
  <p>Thanks,</p>