Another post to track the error Cannot implicitly convert type 'long' to 'int'
public int FindComplement(int num) {
uint i = 0;
uint mask = ~i;
while((mask&num) != 0) mask <<= 1;
//return ~mask^num; //<-- error CS0266
return (int)~mask^num; //<--it works with (int)
}
Sorry for too many questions, I'd like to know why return ~mask^num
will cause error like
error CS0266: Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)
In my environment, return ~mask^num;
will cause error, while return (int)~mask^num
can work. And it seems there is no long
type involved here.