Find largest binary gap of a number N improved This is a follow-up question based on the original one. Could you please see the updated and refactored version and point at things to be improved in term of logic or efficiency?

I have now know as I have been made aware about the Greedy Algorithm; Math.Max and binary shifting which deal more gracefully with the task, however, if I were in a position to be unaware of them and this is the code I managed to write, what's your thoughts on it?

    public static int FindGap(int number)
    {
        string toBinary = Convert.ToString(number, 2);
        char[] toChar = toBinary.ToCharArray();

        char previous = '0';
        char current = '0';
        int maxGap = 0;
        int answer = 0;

        for (int i = 0; i &lt; toChar.Length; i++)
        {
            if (toChar[i] == '1')
            {
                current = toChar[i];

                // keep last/latest largest gap as an answer
                if (answer &lt; maxGap)
                {
                    answer = maxGap;
                }

                // reset if 1 appeared and start counting next gap
                maxGap = 0;
            }
            if ((toChar[i] == '0' &amp;&amp; current == '1') || (toChar[i] == '0' &amp;&amp; previous == '0'))
            {
                current = '0';
                maxGap++;
                previous = current;
            }
        }

        if (answer != 0)
        {
            return answer;
        }
        else return 0;
    }
If I were in a position to be unaware of them and this is the code I
  managed to write, what's your thoughts on it?



No need to call ToCharArray() because you can iterate over the chars of a string as well
By using an else if instead of the second if you won't need to check for toChar[i] == '0' but basically you only need a else. 
Using a foreach loop instead of a for loop seems more natural for this task.  
The returning of the answer can be simply return answer;  
Because ToString(int, 2) strips leading '0' you can remove both current and previous.


Summing up it could look like so  

public static int FindGap(int number)
{
    int maxGap = 0;
    int answer = 0;

    foreach(var c in Convert.ToString(number, 2))
    {
        if (c == '1')
        {
            if (answer &lt; maxGap)
            {
                answer = maxGap;
            }
            maxGap = 0;
        }
        else
        {
            maxGap++;
        }
    }
    return answer;
}