I tried the following code for displaying a number's binary equivalent but i am getting an error and i am not getting the reason behind the error:
using System;
class NumToBin{
static void main(){
int num=7;
for(int i=0;i<=32;i++){
if(num &(1<<i)==1)// getting an error on this line
Console.WriteLine("1");
else
Console.WriteLine("0");
}
Console.ReadKey(true);
}
}
I got the following error for the above code and i dont know the reason behind this error?
Operator '&' cannot be applied to operands of type 'int' and 'bool' (CS0019)