Q: Autohotkey: Convert a function to C# and (&) bitwise operator I have a autohotkey function, which I want to convert/port in c#, but not getting any success. below is the function:
GetBits(ANumber) ; get string with numbers of enabled bits in a parameter
{
    i = 1
    bit = 1
    result =
    loop
    {
        if(bit = 512)
            break
        if(ANumber & bit)
            result = %result% %i%
        bit := 2 * bit
        i := i + 1
    }
    return result
}

specifically, what does this line mean?
if(ANumber & bit)

what will be it's equivalent in c#? can anyone please help me with it?

A: the line if(ANumber & bit) is doing a logical AND and checking if the value is true (non-zero) or false (0)
C# equilent to the line is quite similar
if((ANumber & bit) != 0 )

this would check the if the result is non zero to pass the condition.
for more info see & Operator (C# Reference) 
Full Code
I attempted to convert full code. data types are based on best guess, you may adjust as necessary.
    string GetBits(int ANumber) // get string with numbers of enabled bits in a parameter
    {
        int i = 1;
        int bit = 1;
        string result = string.Empty;
        while (true)
        {
            if (bit == 512)
                break;
            if ((ANumber & bit) != 0)
                result += i.ToString();
            bit = 2 * bit;
            i++;
        }
        return result;
    }

see if this what you are looking for.
