C# Binary Gap
static int BinaryGap(int n)
{
    var binary = Convert.ToString(n, 2).Trim('0');
    var gap = 0;

    foreach (var zero in binary.Split('1'))
    {
        gap = Math.Max(gap, zero.Length);
    }

    return gap;
}

This turns the number into binary, ignores zeroes outside the edges, and finds the longest run of zeroes between 1s.