title: Initialize BitArray from integer
body: <p>I'm trying to initialize a System.BitArray instance from integer value. However, it looks like I don't get the right values.</p>
  
  <p>My code is</p>
  
  <pre><code>        var b = new BitArray(BitConverter.GetBytes(0xfa2));
          for (int i = 0; i &lt; b.Count; i++)
          {
              char c = b[i] ? '1' : '0';
              Console.Write(c);
          }
          Console.WriteLine();
  </code></pre>
  
  <p>I've tried also without BitConverter:</p>
  
  <pre><code>        var b = new BitArray(new int[] { 0xfa2 });
  </code></pre>
  
  <p>But none of these attempt seem to work. These are the attempts that was suggested here: <a href="https://stackoverflow.com/questions/6758196/convert-int-to-a-bit-array-in-net">Convert int to a bit array in .NET</a></p>
  
  <p>My output: 01000101111100000000000000000000.
  The excpected output: 111110100010.</p>
  
  <p>Any help will be really appreciated!</p>