title: How to loop through the number at each index in byte array?
body: <p>I'm coding a program to parse xml to a byte array, and need to check the numeric values at certain indexes within the byte array.</p>
  
  <p>For example if <code>99</code> is an integer within the array, it should write an error message to the console, same for <code>999</code> and <code>01</code>.</p>
  
  <p>What I've tried so far is the using a for each loop, but the if..else conditions are checking the <em>index number</em>, not the <em>integer numbers</em> associated with each index in the array.</p>
  
  <p>Does anyone know how I can loop through the integer values associated with each index? <strong>(shown in the screen shot below)</strong></p>
  
  <p>This is what I've tried so far, but the loop seems to be checking the index values , not the integer values associated with the indexes, giving false results:</p>
  
  <pre><code>private static byte[] requestBytes;
  
  foreach(char i in requestBytes)
  {
      if (i == 99)
      {
          Console.WriteLine("Sending Failure..");
      }
      else if(i == 999)
      {
          Console.WriteLine("Message Failure..");
      }
      else if (i == 01)
      {
          Console.WriteLine("Sending Success..");
      }
  
  }
  </code></pre>
  
  <p>As you can see in the picture, each index has an associated integer value, which I want to check in a loop.</p>
  
  <p><a href="https://i.stack.imgur.com/GRLS0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GRLS0.png" alt="Byte array contents"></a></p>