我正在尝试将负数转换为 8 位二进制形式。这是我的代码:-
UTF8Encoding Bencoding = new UTF8Encoding();
int a=-3;
byte[] Bbuf = Bencoding.GetBytes(a.ToString());
StringBuilder Binfobinary = new StringBuilder();
foreach (byte b in Bbuf)
{
string str = Convert.ToString(b, 2);
Binfobinary.Append(str);
}
它给了我这样的答案 101101110011