Cannot iterate over a bit representation of an int
<p>I need to loop through a bit representation of an integer then I need to calculate the number of zeroes in it. I tired the below code but unfortunately it did not work :</p>

<pre><code>public int calculate(int i)
{
            string a = Convert.ToString(i, 2);
            int[] array = new int[a.Length];
            int number = 0;

            for (int n = 0; n &lt; s.Length; n++)
            {
                iarray[n] = s[n]; // build an array of intigers representing the bits valies such as 0011100
            }

            for (int n = 0; n &lt; array.Length; n++)
            {
                if (array[n] == 0) {
                   number = number + 1;
            }

            return number
}
</code></pre>

<p>Can anyone advice why it is not working as intended ?</p>
