String.PadLeft (Int32, Char)
string xStr = Convert.ToString(x, 2).PadLeft(32, '0');
For test...
#region 使用"~" 按位取反
int x = 12345678;
int y = ~x;
string xStr = Convert.ToString(x, 2).PadLeft(32, '0');
string yStr = Convert.ToString(y, 2).PadLeft(32, '0');
Console.WriteLine(xStr);
Console.WriteLine(yStr);
#endregion
沒有留言:
張貼留言