title: How do you read a byte array from a DataRow in C#?
body: <p>I have a <code>DataSet</code> with a <code>DataTable</code> that correctly fills a single <code>DataRow</code> through a <code>TableAdapter</code>.</p>
  
  <p>I am able to pull data from the DataRow with code like this:</p>
  
  <pre><code>dataFileID = (int)this.dataFileDataRow["DataFileID"];
  dataFileName = (string)this.dataFileDataRow["DataFileName"];
  dataFileDate = (DateTime)this.dataFileDataRow["DataFileDate"];
  </code></pre>
  
  <p>I have another column called DataFile of type <code>varbinary(max)</code>.</p>
  
  <p>When I try to pull that column's data from the same <code>DataRow</code> as above I get nothing.</p>
  
  <pre><code>byte[] fileFromDatabase = (byte[])this.dataFileDataRow["DataFile"];
  </code></pre>
  
  <p>If I put a break point at this location, I can look into the dataFileDataRow, look into the ItemArray property and see that the binary data is sitting at position 5 in the ItemArray.</p>
  
  <p>I have tried access the ItemArray directly using its index but the byte array is not being copied to the fileFromDatabase variable.  </p>
  
  <p>I have also noticed that adding fileFromDatabase to my watch produces this error:         </p>
  
  <blockquote>
    <p>"The name 'fileFromDatabase' does not exist in the current context"</p>
  </blockquote>
  
  <p>The execution is still in the same block as the definition of fileFromDatabase so I do not understand how it would be out of context.</p>
  
  <p>I had Visual Studio's configuration set to Release instead of Debug.  This was causing me to not see the real time debugging information I was looking for when trying to examine fileFromDatabase.  After switching from Release to Debug, I am able to see the variable in the watch now and can verify that the code above is working correctly.  </p>