title: How to Check byte array empty or not?
body: <p>I am downloading the word file for <code>GetSourceAttachment</code> method. When this method returns empty bytes then my byte <code>Attachment</code> array gives an error:</p>
  
  <blockquote>
    <p>Object reference not set instance of object</p>
  </blockquote>
  
  <p>It gives the error when I check the length of <code>Attachment</code> in <code>if</code> condition. </p>
  
  <p>Can any one help me to default initialize the byte array, then check the length?</p>
  
  <pre><code>try
  {
          byte[] Attachment = null ;
  
          string Extension = string.Empty;
          ClsPortalManager objPortalManager = new ClsPortalManager();
          Attachment = objPortalManager.GetSourceAttachment(Convert.ToInt32(hdnSourceId.Value), out Extension);
          if (Attachment.Length &gt; 0 &amp;&amp; Attachment != null)
          {
              DownloadAttachment("Attacment", Attachment, Extension);
          }
          else
          {
              ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "&lt;script type='text/javascript'&gt;alert('Attachment is not Uploaded !');&lt;/script&gt;");
          }            
  }
  catch
  {
  
  }
  </code></pre>