abd*_*ahS 0 c# signed byte type-conversion
oxfc是负面的,但我把它作为a byte,它的值是252,有没有办法将其转换为签名byte或int?
我找到了这个方法:
(BitConverter.ToInt16(new byte[2] { 0, 0xfc }, 0) / 256).ToString()
Run Code Online (Sandbox Code Playgroud)
但还有更好的方法吗?
你可以简单地投下它:
byte b = 0xfc;
sbyte s = unchecked((sbyte)b);
Run Code Online (Sandbox Code Playgroud)