整数转成二进制含有一的个数 int num = 0; while ((bt>>=1)!= 0) { num += bt & 1; } Console.WriteLine("该数有{0}个1", num);