title: C# Number to BitMask32 to Values
body: <p>I am getting a number such as 513. I need to convert this number to a bitmask32 then I need to count where each 1 bit is in the array</p>
  
  <p>For Example
  513 = 0 and 9</p>
  
  <p>How would I go about converting the number to a bit32 then reading the values?</p>
  
  <p>Right now I am just converting the number to a string binary value:</p>
  
  <pre><code>string bit = Convert.ToString(513, 2);
  </code></pre>
  
  <p>Would there be a more effective way to do this? How would I convert the value to a bit array?</p>
  
  <p>Thanks</p>