title: Checking equality for two byte arrays
body: <p>I am checking the equality of two byte arrays, and I wanted some help because what I have returns false even though the arrays should be equal.</p>
  
  <p>Within my debug I could see both of a1 and b1 are equal, but it is not going inside the while loop to increment i.</p>
  
  <pre><code>public bool Equality(byte[] a1, byte[] b1)
  {
      int i;
      bool bEqual;
      if (a1.Length == b1.Length)
      {
          i = 0;
          while ((i &lt; a1.Length) &amp;&amp; (a1[i]==b1[i]))
          {
              i++;
          }
  
          if (i == a1.Length)
          {
              bEqual = true;
          }
      }
      return bEqual;
  }
  </code></pre>
  
  <p>This always returns false: <code>(a1[i]==b1[i])</code>.</p>